diff --git a/atom/CPPLINT.cfg b/atom/CPPLINT.cfg deleted file mode 100644 index 8efb41d55c2..00000000000 --- a/atom/CPPLINT.cfg +++ /dev/null @@ -1 +0,0 @@ -filter=+build/include_alpha diff --git a/atom/app/atom_content_client.cc b/atom/app/atom_content_client.cc index f366691b2a3..a3572d80ad6 100644 --- a/atom/app/atom_content_client.cc +++ b/atom/app/atom_content_client.cc @@ -61,17 +61,16 @@ content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, flash_version_numbers.push_back("999"); // E.g., "Shockwave Flash 10.2 r154": plugin.description = plugin.name + " " + flash_version_numbers[0] + "." + - flash_version_numbers[1] + " r" + flash_version_numbers[2]; + flash_version_numbers[1] + " r" + + flash_version_numbers[2]; plugin.version = base::JoinString(flash_version_numbers, "."); - content::WebPluginMimeType swf_mime_type( - content::kFlashPluginSwfMimeType, - content::kFlashPluginSwfExtension, - content::kFlashPluginSwfDescription); + content::WebPluginMimeType swf_mime_type(content::kFlashPluginSwfMimeType, + content::kFlashPluginSwfExtension, + content::kFlashPluginSwfDescription); plugin.mime_types.push_back(swf_mime_type); - content::WebPluginMimeType spl_mime_type( - content::kFlashPluginSplMimeType, - content::kFlashPluginSplExtension, - content::kFlashPluginSplDescription); + content::WebPluginMimeType spl_mime_type(content::kFlashPluginSplMimeType, + content::kFlashPluginSplExtension, + content::kFlashPluginSplDescription); plugin.mime_types.push_back(spl_mime_type); return plugin; @@ -84,13 +83,11 @@ content::PepperPluginInfo CreateWidevineCdmInfo(const base::FilePath& path, widevine_cdm.is_out_of_process = true; widevine_cdm.path = path; widevine_cdm.name = kWidevineCdmDisplayName; - widevine_cdm.description = kWidevineCdmDescription + - std::string(" (version: ") + - version + ")"; + widevine_cdm.description = + kWidevineCdmDescription + std::string(" (version: ") + version + ")"; widevine_cdm.version = version; content::WebPluginMimeType widevine_cdm_mime_type( - kWidevineCdmPluginMimeType, - kWidevineCdmPluginExtension, + kWidevineCdmPluginMimeType, kWidevineCdmPluginExtension, kWidevineCdmPluginMimeTypeDescription); // Add the supported codecs as if they came from the component manifest. @@ -142,8 +139,7 @@ void ConvertStringWithSeparatorToVector(std::vector* vec, auto string_with_separator = command_line->GetSwitchValueASCII(cmd_switch); if (!string_with_separator.empty()) *vec = base::SplitString(string_with_separator, separator, - base::TRIM_WHITESPACE, - base::SPLIT_WANT_NONEMPTY); + base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); } } // namespace @@ -151,13 +147,13 @@ void ConvertStringWithSeparatorToVector(std::vector* vec, void AddPepperFlashFromCommandLine( std::vector* plugins) { auto command_line = base::CommandLine::ForCurrentProcess(); - base::FilePath flash_path = command_line->GetSwitchValuePath( - switches::kPpapiFlashPath); + base::FilePath flash_path = + command_line->GetSwitchValuePath(switches::kPpapiFlashPath); if (flash_path.empty()) return; - auto flash_version = command_line->GetSwitchValueASCII( - switches::kPpapiFlashVersion); + auto flash_version = + command_line->GetSwitchValueASCII(switches::kPpapiFlashVersion); plugins->push_back(CreatePepperFlashInfo(flash_path, flash_version)); } @@ -166,38 +162,36 @@ void AddPepperFlashFromCommandLine( void AddWidevineCdmFromCommandLine( std::vector* plugins) { auto command_line = base::CommandLine::ForCurrentProcess(); - base::FilePath widevine_cdm_path = command_line->GetSwitchValuePath( - switches::kWidevineCdmPath); + base::FilePath widevine_cdm_path = + command_line->GetSwitchValuePath(switches::kWidevineCdmPath); if (widevine_cdm_path.empty()) return; if (!base::PathExists(widevine_cdm_path)) return; - auto widevine_cdm_version = command_line->GetSwitchValueASCII( - switches::kWidevineCdmVersion); + auto widevine_cdm_version = + command_line->GetSwitchValueASCII(switches::kWidevineCdmVersion); if (widevine_cdm_version.empty()) return; - plugins->push_back(CreateWidevineCdmInfo(widevine_cdm_path, - widevine_cdm_version)); + plugins->push_back( + CreateWidevineCdmInfo(widevine_cdm_path, widevine_cdm_version)); } #endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS) -AtomContentClient::AtomContentClient() { -} +AtomContentClient::AtomContentClient() {} -AtomContentClient::~AtomContentClient() { -} +AtomContentClient::~AtomContentClient() {} std::string AtomContentClient::GetProduct() const { return "Chrome/" CHROME_VERSION_STRING; } std::string AtomContentClient::GetUserAgent() const { - return content::BuildUserAgentFromProduct( - "Chrome/" CHROME_VERSION_STRING " " - ATOM_PRODUCT_NAME "/" ATOM_VERSION_STRING); + return content::BuildUserAgentFromProduct("Chrome/" CHROME_VERSION_STRING + " " ATOM_PRODUCT_NAME + "/" ATOM_VERSION_STRING); } base::string16 AtomContentClient::GetLocalizedString(int message_id) const { diff --git a/atom/app/atom_library_main.h b/atom/app/atom_library_main.h index fc95b4d0fee..2c7a27caa20 100644 --- a/atom/app/atom_library_main.h +++ b/atom/app/atom_library_main.h @@ -9,12 +9,12 @@ #if defined(OS_MACOSX) extern "C" { -__attribute__((visibility("default"))) -int AtomMain(int argc, char* argv[]); +__attribute__((visibility("default"))) int AtomMain(int argc, char* argv[]); #ifdef ENABLE_RUN_AS_NODE -__attribute__((visibility("default"))) -int AtomInitializeICUandStartNode(int argc, char *argv[]); +__attribute__((visibility("default"))) int AtomInitializeICUandStartNode( + int argc, + char* argv[]); #endif } #endif // OS_MACOSX diff --git a/atom/app/atom_main.cc b/atom/app/atom_main.cc index 53e025d2808..41c11c4704b 100644 --- a/atom/app/atom_main.cc +++ b/atom/app/atom_main.cc @@ -24,7 +24,7 @@ #include "base/win/windows_version.h" #include "content/public/app/sandbox_helper_win.h" #include "sandbox/win/src/sandbox_types.h" -#elif defined(OS_LINUX) // defined(OS_WIN) +#elif defined(OS_LINUX) // defined(OS_WIN) #include "atom/app/atom_main_delegate.h" // NOLINT #include "content/public/app/content_main.h" #else // defined(OS_LINUX) @@ -117,9 +117,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) { // from within the CRT's atexit facility, ensuring the heap functions are // still active. The second invocation from the OS loader will be a no-op. extern void NTAPI OnThreadExit(PVOID module, DWORD reason, PVOID reserved); - atexit([]() { - OnThreadExit(nullptr, DLL_THREAD_DETACH, nullptr); - }); + atexit([]() { OnThreadExit(nullptr, DLL_THREAD_DETACH, nullptr); }); #endif #ifdef ENABLE_RUN_AS_NODE diff --git a/atom/app/atom_main_delegate.cc b/atom/app/atom_main_delegate.cc index 9ae106af589..0d817865b0a 100644 --- a/atom/app/atom_main_delegate.cc +++ b/atom/app/atom_main_delegate.cc @@ -45,19 +45,20 @@ bool IsBrowserProcess(base::CommandLine* cmd) { } #if defined(OS_WIN) -void InvalidParameterHandler(const wchar_t*, const wchar_t*, const wchar_t*, - unsigned int, uintptr_t) { +void InvalidParameterHandler(const wchar_t*, + const wchar_t*, + const wchar_t*, + unsigned int, + uintptr_t) { // noop. } #endif } // namespace -AtomMainDelegate::AtomMainDelegate() { -} +AtomMainDelegate::AtomMainDelegate() {} -AtomMainDelegate::~AtomMainDelegate() { -} +AtomMainDelegate::~AtomMainDelegate() {} bool AtomMainDelegate::BasicStartupComplete(int* exit_code) { auto command_line = base::CommandLine::ForCurrentProcess(); @@ -77,7 +78,7 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) { #else settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; #endif // defined(DEBUG) -#else // defined(OS_WIN) +#else // defined(OS_WIN) settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; #endif // !defined(OS_WIN) @@ -129,8 +130,8 @@ void AtomMainDelegate::PreSandboxStartup() { brightray::MainDelegate::PreSandboxStartup(); auto command_line = base::CommandLine::ForCurrentProcess(); - std::string process_type = command_line->GetSwitchValueASCII( - ::switches::kProcessType); + std::string process_type = + command_line->GetSwitchValueASCII(::switches::kProcessType); // Only append arguments for browser process. if (!IsBrowserProcess(command_line)) @@ -162,11 +163,11 @@ content::ContentBrowserClient* AtomMainDelegate::CreateContentBrowserClient() { } content::ContentRendererClient* - AtomMainDelegate::CreateContentRendererClient() { +AtomMainDelegate::CreateContentRendererClient() { if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableSandbox) || + switches::kEnableSandbox) || !base::CommandLine::ForCurrentProcess()->HasSwitch( - ::switches::kNoSandbox)) { + ::switches::kNoSandbox)) { renderer_client_.reset(new AtomSandboxedRendererClient); } else { renderer_client_.reset(new AtomRendererClient); diff --git a/atom/app/command_line_args.cc b/atom/app/command_line_args.cc index 9472d1cb9fd..f0576ec26d1 100644 --- a/atom/app/command_line_args.cc +++ b/atom/app/command_line_args.cc @@ -53,1317 +53,1317 @@ bool IsUrlArg(const base::CommandLine::CharType* arg) { */ const char* kBlacklist[] = { - "/prefetch:1", - "/prefetch:2", - "/prefetch:3", - "/prefetch:4", - "/prefetch:5", - "/prefetch:6", - "/prefetch:8", - "0", - "?", - "ChromeOSMemoryPressureHandling", - "SafeSites", - "accept-resource-provider", - "account-consistency", - "adaboost", - "aec-refined-adaptive-filter", - "agc-startup-min-volume", - "aggressive", - "aggressive-cache-discard", - "aggressive-tab-discard", - "all", - "all-toolchains", - "allarticles", - "allow-cross-origin-auth-prompt", - "allow-external-pages", - "allow-failed-policy-fetch-for-test", - "allow-file-access-from-files", - "allow-hidden-media-playback", - "allow-http-background-page", - "allow-http-screen-capture", - "allow-insecure-localhost", - "allow-legacy-extension-manifests", - "allow-loopback-in-peer-connection", - "allow-nacl-crxfs-api", - "allow-nacl-file-handle-api", - "allow-nacl-socket-api", - "allow-no-sandbox-job", - "allow-outdated-plugins", - "allow-ra-in-dev-mode", - "allow-running-insecure-content", - "allow-sandbox-debugging", - "allow-silent-push", - "alsa-check-close-timeout", - "alsa-enable-upsampling", - "alsa-fixed-output-sample-rate", - "alsa-input-device", - "alsa-mute-device-name", - "alsa-mute-element-name", - "alsa-output-avail-min", - "alsa-output-buffer-size", - "alsa-output-device", - "alsa-output-period-size", - "alsa-output-start-threshold", - "alsa-volume-device-name", - "alsa-volume-element-name", - "also-emit-success-logs", - "alternative", - "always-authorize-plugins", - "always-on", - "always-use-complex-text", - "alwaystrue", - "amd-switchable", - "android-fonts-path", - "android-stderr-port", - "android-stdin-port", - "android-stdout-port", - "angle", - "app", - "app-auto-launched", - "app-id", - "app-mode-auth-code", - "app-mode-oauth-token", - "app-mode-oem-manifest", - "app-shell-allow-roaming", - "app-shell-host-window-size", - "app-shell-preferred-network", - "app-shell-refresh-token", - "app-shell-user", - "apple", - "apps-gallery-download-url", - "apps-gallery-update-url", - "apps-gallery-url", - "apps-keep-chrome-alive-in-tests", - "arc-availability", - "arc-available", - "arc-start-mode", - "arc-transition-migration-required", - "args", - "artifacts-dir", - "ash-constrain-pointer-to-root", - "ash-debug-shortcuts", - "ash-dev-shortcuts", - "ash-disable-smooth-screen-rotation", - "ash-disable-tablet-autohide-titlebars", - "ash-disable-touch-exploration-mode", - "ash-enable-magnifier-key-scroller", - "ash-enable-mirrored-screen", - "ash-enable-night-light", - "ash-enable-palette-on-all-displays", - "ash-enable-scale-settings-tray", - "ash-enable-software-mirroring", - "ash-enable-unified-desktop", - "ash-estimated-presentation-delay", - "ash-hide-notifications-for-factory", - "ash-host-window-bounds", - "ash-shelf-color", - "ash-shelf-color-scheme", - "ash-touch-hud", - "ash-webui-init", - "attestation-server", - "audio-buffer-size", - "audio-output-channels", - "aura-legacy-power-button", - "auth-ext-path", - "auth-server-whitelist", - "auth-spnego-account-type", - "auto", - "auto-open-devtools-for-tabs", - "auto-select-desktop-capture-source", - "autoplay-policy", - "blink-settings", - "bootstrap", - "browser", - "browser-startup-dialog", - "browser-subprocess-path", - "browser-test", - "bwsi", - "bypass-app-banner-engagement-checks", - "canvas-msaa-sample-count", - "cast-initial-screen-height", - "cast-initial-screen-width", - "cc-layer-tree-test-long-timeout", - "cc-layer-tree-test-no-timeout", - "cc-rebaseline-pixeltests", - "cellular-first", - "cellular-only", - "check-for-update-interval", - "check-layout-test-sys-deps", - "child-wallpaper-large", - "child-wallpaper-small", - "chrome-home-swipe-logic", - "cipher-suite-blacklist", - "clamshell", - "class", - "clear-token-service", - "cloud-print-file", - "cloud-print-file-type", - "cloud-print-job-title", - "cloud-print-print-ticket", - "cloud-print-setup-proxy", - "cloud-print-url", - "cloud-print-xmpp-endpoint", - "color", - "compensate-for-unstable-pinch-zoom", - "compile-shader-always-succeeds", - "component-updater", - "connectivity-check-url", - "conservative", - "content-image-texture-target", - "content-shell-host-window-size", - "controller", - "crash-dumps-dir", - "crash-on-failure", - "crash-on-hang-threads", - "crash-server-url", - "crash-test", - "crashpad-handler", - "create-browser-on-startup-for-tests", - "cros-gaia-api-v1", - "cros-region", - "cros-regions-mode", - "crosh-command", - "cryptauth-http-host", - "custom-devtools-frontend", - "custom-launcher-page", - "custom_summary", - "d3d-support", - "d3d11", - "d3d9", - "daemon", - "dark_muted", - "dark_vibrant", - "data-path", - "data-reduction-proxy-config-url", - "data-reduction-proxy-experiment", - "data-reduction-proxy-http-proxies", - "data-reduction-proxy-lo-fi", - "data-reduction-proxy-pingback-url", - "data-reduction-proxy-secure-proxy-check-url", - "data-reduction-proxy-server-experiments-disabled", - "dbus-stub", - "debug-devtools", - "debug-enable-frame-toggle", - "debug-packed-apps", - "debug-print", - "default", - "default-background-color", - "default-tile-height", - "default-tile-width", - "default-wallpaper-is-oem", - "default-wallpaper-large", - "default-wallpaper-small", - "demo", - "derelict-detection-timeout", - "derelict-idle-timeout", - "desktop", - "desktop-window-1080p", - "deterministic-fetch", - "device-management-url", - "device-scale-factor", - "devtools-flags", - "diagnostics", - "diagnostics-format", - "diagnostics-recovery", - "dice", - "dice_fix_auth_errors", - "disable", - "disable-2d-canvas-clip-aa", - "disable-2d-canvas-image-chromium", - "disable-3d-apis", - "disable-accelerated-2d-canvas", - "disable-accelerated-jpeg-decoding", - "disable-accelerated-mjpeg-decode", - "disable-accelerated-video-decode", - "disable-app-info-dialog-mac", - "disable-app-list-dismiss-on-blur", - "disable-app-window-cycling", - "disable-appcontainer", - "disable-arc-data-wipe", - "disable-arc-opt-in-verification", - "disable-audio-support-for-desktop-share", - "disable-avfoundation-overlays", - "disable-background-networking", - "disable-background-timer-throttling", - "disable-backgrounding-occluded-windows", - "disable-backing-store-limit", - "disable-blink-features", - "disable-boot-animation", - "disable-breakpad", - "disable-browser-task-scheduler", - "disable-bundled-ppapi-flash", - "disable-canvas-aa", - "disable-captive-portal-bypass-proxy", - "disable-cast-streaming-hw-encoding", - "disable-checker-imaging", - "disable-clear-browsing-data-counters", - "disable-client-side-phishing-detection", - "disable-cloud-import", - "disable-component-cloud-policy", - "disable-component-extensions-with-background-pages", - "disable-component-update", - "disable-composited-antialiasing", - "disable-contextual-search", - "disable-d3d11", - "disable-databases", - "disable-datasaver-prompt", - "disable-default-apps", - "disable-demo-mode", - "disable-device-disabling", - "disable-device-discovery-notifications", - "disable-dinosaur-easter-egg", - "disable-direct-composition", - "disable-direct-composition-layers", - "disable-directwrite-for-ui", - "disable-display-list-2d-canvas", - "disable-distance-field-text", - "disable-domain-blocking-for-3d-apis", - "disable-domain-reliability", - "disable-drive-search-in-app-launcher", - "disable-dwm-composition", - "disable-encryption-migration", - "disable-eol-notification", - "disable-es3-apis", - "disable-es3-gl-context", - "disable-extensions", - "disable-extensions-except", - "disable-extensions-file-access-check", - "disable-extensions-http-throttling", - "disable-features", - "disable-field-trial-config", - "disable-file-manager-touch-mode", - "disable-file-system", - "disable-flash-3d", - "disable-flash-stage3d", - "disable-fullscreen-low-power-mode", - "disable-fullscreen-tab-detaching", - "disable-gaia-services", - "disable-gesture-editing", - "disable-gesture-requirement-for-presentation", - "disable-gesture-typing", - "disable-gl-drawing-for-tests", - "disable-gl-error-limit", - "disable-gl-extensions", - "disable-glsl-translator", - "disable-gpu", - "disable-gpu-compositing", - "disable-gpu-driver-bug-workarounds", - "disable-gpu-early-init", - "disable-gpu-memory-buffer-compositor-resources", - "disable-gpu-memory-buffer-video-frames", - "disable-gpu-process-crash-limit", - "disable-gpu-program-cache", - "disable-gpu-rasterization", - "disable-gpu-sandbox", - "disable-gpu-shader-disk-cache", - "disable-gpu-vsync", - "disable-gpu-watchdog", - "disable-hang-monitor", - "disable-hid-detection-on-oobe", - "disable-histogram-customizer", - "disable-hosted-app-shim-creation", - "disable-hosted-apps-in-windows", - "disable-in-process-stack-traces", - "disable-infobars", - "disable-input-ime-api", - "disable-input-view", - "disable-ios-password-suggestions", - "disable-javascript-harmony-shipping", - "disable-kill-after-bad-ipc", - "disable-lcd-text", - "disable-legacy-window", - "disable-local-storage", - "disable-lock-screen-apps", - "disable-logging", - "disable-logging-redirect", - "disable-login-animations", - "disable-login-screen-apps", - "disable-low-end-device-mode", - "disable-low-latency-dxva", - "disable-low-res-tiling", - "disable-mac-overlays", - "disable-mac-views-native-app-windows", - "disable-machine-cert-request", - "disable-main-frame-before-activation", - "disable-md-error-screen", - "disable-md-oobe", - "disable-media-session-api", - "disable-media-suspend", - "disable-merge-key-char-events", - "disable-mojo-local-storage", - "disable-mojo-renderer", - "disable-mtp-write-support", - "disable-multi-display-layout", - "disable-namespace-sandbox", - "disable-native-gpu-memory-buffers", - "disable-network-portal-notification", - "disable-new-korean-ime", - "disable-new-virtual-keyboard-behavior", - "disable-new-zip-unpacker", - "disable-notifications", - "disable-ntp-most-likely-favicons-from-server", - "disable-ntp-popular-sites", - "disable-nv12-dxgi-video", - "disable-offer-store-unmasked-wallet-cards", - "disable-offer-upload-credit-cards", - "disable-office-editing-component-extension", - "disable-offline-auto-reload", - "disable-offline-auto-reload-visible-only", - "disable-origin-trial-controlled-blink-features", - "disable-overscroll-edge-effect", - "disable-panel-fitting", - "disable-partial-raster", - "disable-password-generation", - "disable-pepper-3d", - "disable-pepper-3d-image-chromium", - "disable-per-user-timezone", - "disable-permission-action-reporting", - "disable-permissions-api", - "disable-physical-keyboard-autocorrect", - "disable-pinch", - "disable-pnacl-crash-throttling", - "disable-popup-blocking", - "disable-prefer-compositing-to-lcd-text", - "disable-presentation-api", - "disable-print-preview", - "disable-prompt-on-repost", - "disable-proximity-auth-bluetooth-low-energy-discovery", - "disable-pull-to-refresh-effect", - "disable-push-api-background-mode", - "disable-reading-from-canvas", - "disable-remote-core-animation", - "disable-remote-fonts", - "disable-remote-playback-api", - "disable-renderer-accessibility", - "disable-renderer-backgrounding", - "disable-resize-lock", - "disable-rgba-4444-textures", - "disable-rollback-option", - "disable-rtc-smoothness-algorithm", - "disable-screen-orientation-lock", - "disable-search-geolocation-disclosure", - "disable-seccomp-filter-sandbox", - "disable-setuid-sandbox", - "disable-shader-name-hashing", - "disable-shared-workers", - "disable-signin-promo", - "disable-signin-scoped-device-id", - "disable-single-click-autofill", - "disable-skia-runtime-opts", - "disable-slim-navigation-manager", - "disable-slimming-paint-invalidation", - "disable-smooth-scrolling", - "disable-software-rasterizer", - "disable-speech-api", - "disable-suggestions-ui", - "disable-surface-references", - "disable-sync", - "disable-sync-app-list", - "disable-sync-types", - "disable-system-timezone-automatic-detection", - "disable-tab-for-desktop-share", - "disable-third-party-keyboard-workaround", - "disable-threaded-animation", - "disable-threaded-compositing", - "disable-threaded-scrolling", - "disable-timeouts-for-profiling", - "disable-touch-adjustment", - "disable-touch-drag-drop", - "disable-translate-new-ux", - "disable-usb-keyboard-detect", - "disable-v8-idle-tasks", - "disable-vaapi-accelerated-video-encode", - "disable-virtual-keyboard-overscroll", - "disable-voice-input", - "disable-volume-adjust-sound", - "disable-wake-on-wifi", - "disable-web-notification-custom-layouts", - "disable-web-security", - "disable-webgl", - "disable-webgl-image-chromium", - "disable-webrtc-encryption", - "disable-webrtc-hw-decoding", - "disable-webrtc-hw-encoding", - "disable-win32k-lockdown", - "disable-xss-auditor", - "disable-zero-browsers-open-for-tests", - "disable-zero-copy", - "disable-zero-copy-dxgi-video", - "disabled", - "disabled-new-style-notification", - "disallow-non-exact-resource-reuse", - "disk-cache-dir", - "disk-cache-size", - "display", - "dmg-device", - "dns-log-details", - "document-user-activation-required", - "dom-automation", - "dotfile", - "draft", - "draw-view-bounds-rects", - "duck-flash", - "dump-blink-runtime-call-stats", - "dump-browser-histograms", - "dump-dom", - "eafe-path", - "eafe-url", - "easy-unlock-app-path", - "edge-touch-filtering", - "egl", - "elevate", - "embedded-extension-options", - "emphasize-titles-in-omnibox-dropdown", - "emulate-shader-precision", - "enable-accelerated-2d-canvas", - "enable-accelerated-vpx-decode", - "enable-accessibility-tab-switcher", - "enable-adaptive-selection-handle-orientation", - "enable-aggressive-domstorage-flushing", - "enable-android-wallpapers-app", - "enable-app-info-dialog-mac", - "enable-app-list", - "enable-app-window-cycling", - "enable-appcontainer", - "enable-arc", - "enable-arc-oobe-optin", - "enable-async-event-targeting", - "enable-audio-debug-recordings-from-extension", - "enable-audio-focus", - "enable-automation", - "enable-background-fetch-persistence", - "enable-benchmarking", - "enable-ble-advertising-in-apps", - "enable-blink-features", - "enable-bookmark-undo", - "enable-browser-side-navigation", - "enable-browser-task-scheduler", - "enable-cast-receiver", - "enable-checker-imaging", - "enable-chromevox-arc-support", - "enable-clear-browsing-data-counters", - "enable-cloud-print-proxy", - "enable-cloud-print-xps", - "enable-consumer-kiosk", - "enable-contextual-search", - "enable-crash-reporter", - "enable-crash-reporter-for-testing", - "enable-crx-hash-check", - "enable-data-reduction-proxy-bypass-warning", - "enable-data-reduction-proxy-force-pingback", - "enable-data-reduction-proxy-lite-page", - "enable-data-reduction-proxy-savings-promo", - "enable-datasaver-prompt", - "enable-device-discovery-notifications", - "enable-devtools-experiments", - "enable-direct-composition-layers", - "enable-display-list-2d-canvas", - "enable-distance-field-text", - "enable-distillability-service", - "enable-dom-distiller", - "enable-domain-reliability", - "enable-drive-search-in-app-launcher", - "enable-drm-atomic", - "enable-embedded-extension-options", - "enable-encryption-migration", - "enable-encryption-selection", - "enable-es3-apis", - "enable-exclusive-audio", - "enable-experimental-accessibility-features", - "enable-experimental-canvas-features", - "enable-experimental-extension-apis", - "enable-experimental-fullscreen-exit-ui", - "enable-experimental-input-view-features", - "enable-experimental-web-platform-features", - "enable-extension-activity-log-testing", - "enable-extension-activity-logging", - "enable-extension-assets-sharing", - "enable-external-drive-rename", - "enable-fast-unload", - "enable-features", - "enable-file-manager-touch-mode", - "enable-first-run-ui-transitions", - "enable-floating-virtual-keyboard", - "enable-font-antialiasing", - "enable-fullscreen-tab-detaching", - "enable-fullscreen-toolbar-reveal", - "enable-google-branded-context-menu", - "enable-gpu-async-worker-context", - "enable-gpu-benchmarking", - "enable-gpu-client-logging", - "enable-gpu-client-tracing", - "enable-gpu-command-logging", - "enable-gpu-debugging", - "enable-gpu-driver-debug-logging", - "enable-gpu-memory-buffer-compositor-resources", - "enable-gpu-memory-buffer-video-frames", - "enable-gpu-rasterization", - "enable-gpu-service-logging", - "enable-gpu-service-tracing", - "enable-hardware-overlays", - "enable-harfbuzz-rendertext", - "enable-heap-profiling", - "enable-hosted-app-quit-notification", - "enable-hosted-apps-in-windows", - "enable-hotword-hardware", - "enable-hung-renderer-infobar", - "enable-inband-text-tracks", - "enable-input-ime-api", - "enable-instant-tethering", - "enable-internal-media-session", - "enable-ios-handoff-to-other-devices", - "enable-layer-lists", - "enable-lcd-text", - "enable-leak-detection", - "enable-local-file-accesses", - "enable-local-sync-backend", - "enable-logging", - "enable-longpress-drag-selection", - "enable-low-end-device-mode", - "enable-low-res-tiling", - "enable-mac-views-native-app-windows", - "enable-main-frame-before-activation", - "enable-md-feedback", - "enable-media-suspend", - "enable-merge-key-char-events", - "enable-message-center-always-scroll-up-upon-notification-removal", - "enable-nacl", - "enable-nacl-debug", - "enable-nacl-nonsfi-mode", - "enable-native-gpu-memory-buffers", - "enable-natural-scroll-default", - "enable-navigation-tracing", - "enable-net-benchmarking", - "enable-network-information-downlink-max", - "enable-network-portal-notification", - "enable-new-app-menu-icon", - "enable-ntp-most-likely-favicons-from-server", - "enable-ntp-popular-sites", - "enable-ntp-search-engine-country-detection", - "enable-offer-store-unmasked-wallet-cards", - "enable-offer-upload-credit-cards", - "enable-offline-auto-reload", - "enable-offline-auto-reload-visible-only", - "enable-oop-rasterization", - "enable-osk-overscroll", - "enable-override-bookmarks-ui", - "enable-partial-raster", - "enable-password-generation", - "enable-pepper-testing", - "enable-permission-action-reporting", - "enable-physical-keyboard-autocorrect", - "enable-picture-in-picture", - "enable-pinch", - "enable-pixel-canvas-recording", - "enable-pixel-output-in-tests", - "enable-plugin-placeholder-testing", - "enable-potentially-annoying-security-features", - "enable-power-overlay", - "enable-precise-memory-info", - "enable-prefer-compositing-to-lcd-text", - "enable-print-browser", - "enable-print-preview-register-promos", - "enable-profile-shortcut-manager", - "enable-profiling", - "enable-push-api-background-mode", - "enable-refresh-token-annotation-request", - "enable-request-tablet-site", - "enable-rgba-4444-textures", - "enable-sandbox", - "enable-sandbox-logging", - "enable-screenshot-testing-with-mode", - "enable-scripts-require-action", - "enable-scroll-prediction", - "enable-service-manager-tracing", - "enable-sgi-video-sync", - "enable-signin-promo", - "enable-single-click-autofill", - "enable-site-settings", - "enable-skia-benchmarking", - "enable-slim-navigation-manager", - "enable-slimming-paint-invalidation", - "enable-slimming-paint-v2", - "enable-smooth-scrolling", - "enable-spatial-navigation", - "enable-spdy-proxy-auth", - "enable-speech-dispatcher", - "enable-spelling-feedback-field-trial", - "enable-spotlight-actions", - "enable-stats-collection-bindings", - "enable-stats-table", - "enable-strict-mixed-content-checking", - "enable-strict-powerful-feature-restrictions", - "enable-suggestions-ui", - "enable-suggestions-with-substring-match", - "enable-supervised-user-managed-bookmarks-folder", - "enable-surface-synchronization", - "enable-swap-buffers-with-bounds", - "enable-sync-app-list", - "enable-sync-articles", - "enable-tab-audio-muting", - "enable-tablet-splitview", - "enable-tcp-fastopen", - "enable-third-party-keyboard-workaround", - "enable-threaded-compositing", - "enable-threaded-texture-mailboxes", - "enable-tile-compression", - "enable-touch-calibration-setting", - "enable-touch-drag-drop", - "enable-touchpad-three-finger-click", - "enable-touchview", - "enable-trace-app-source", - "enable-tracing", - "enable-tracing-output", - "enable-translate-new-ux", - "enable-ui-devtools", - "enable-use-zoom-for-dsf", - "enable-user-metrics", - "enable-usermedia-screen-capturing", - "enable-video-player-chromecast-support", - "enable-viewport", - "enable-virtual-keyboard", - "enable-voice-interaction", - "enable-vtune-support", - "enable-vulkan", - "enable-wayland-server", - "enable-web-notification-custom-layouts", - "enable-webfonts-intervention-trigger", - "enable-webfonts-intervention-v2", - "enable-webgl-draft-extensions", - "enable-webgl-image-chromium", - "enable-webrtc-event-logging-from-extension", - "enable-webrtc-srtp-aes-gcm", - "enable-webrtc-srtp-encrypted-headers", - "enable-webrtc-stun-origin", - "enable-webview-variations", - "enable-webvr", - "enable-wifi-credential-sync", - "enable-win7-webrtc-hw-h264-decoding", - "enable-zero-copy", - "enable-zip-archiver-on-file-manager", - "enabled", - "enabled-2g", - "enabled-3g", - "enabled-new-style-notification", - "enabled-slow2g", - "encode-binary", - "enforce", - "enforce-gl-minimums", - "enforce-webrtc-ip-permission-check", - "enforce_strict", - "enterprise-disable-arc", - "enterprise-enable-forced-re-enrollment", - "enterprise-enable-license-type-selection", - "enterprise-enable-zero-touch-enrollment", - "enterprise-enrollment-initial-modulus", - "enterprise-enrollment-modulus-limit", - "error-console", - "evaluate-type", - "evaluate_capability", - "experiment", - "explicitly-allowed-ports", - "expose-internals-for-testing", - "extension-content-verification", - "extension-process", - "extensions-install-verification", - "extensions-multi-account", - "extensions-not-webstore", - "extensions-on-chrome-urls", - "extensions-update-frequency", - "extra-search-query-params", - "fail-on-unused-args", - "fake-variations-channel", - "false", - "fast", - "fast-start", - "feedback-server", - "field-trial-handle", - "first-exec-after-boot", - "flag-switches-begin", - "flag-switches-end", - "font-cache-shared-handle", - "force-android-app-mode", - "force-app-mode", - "force-clamshell-power-button", - "force-color-profile", - "force-desktop-ios-promotion", - "force-dev-mode-highlighting", - "force-device-scale-factor", - "force-display-list-2d-canvas", - "force-effective-connection-type", - "force-enable-metrics-reporting", - "force-enable-stylus-tools", - "force-fieldtrial-params", - "force-fieldtrials", - "force-first-run", - "force-first-run-ui", - "force-gpu-mem-available-mb", - "force-gpu-rasterization", - "force-happiness-tracking-system", - "force-load-easy-unlock-app-in-tests", - "force-local-ntp", - "force-login-manager-in-tests", - "force-mediafoundation", - "force-overlay-fullscreen-video", - "force-password-reauth", - "force-pnacl-subzero", - "force-presentation-receiver-for-testing", - "force-renderer-accessibility", - "force-show-update-menu-badge", - "force-show-update-menu-item", - "force-system-compositor-mode", - "force-tablet-mode", - "force-text-direction", - "force-ui-direction", - "force-variation-ids", - "force-video-overlays", - "force-wave-audio", - "force-webrtc-ip-handling-policy", - "full-memory-crash-report", - "gaia-url", - "gcm-checkin-url", - "gcm-mcs-endpoint", - "gcm-registration-url", - "generate-accessibility-test-expectations", - "gl", - "gl-composited-overlay-candidate-quad-border", - "gl-shader-interm-output", - "gles", - "golden-screenshots-dir", - "google-apis-url", - "google-base-url", - "google-doodle-url", - "google-url", - "gpu-active-device-id", - "gpu-active-vendor-id", - "gpu-device-id", - "gpu-driver-date", - "gpu-driver-vendor", - "gpu-driver-version", - "gpu-launcher", - "gpu-no-complete-info-collection", - "gpu-no-context-lost", - "gpu-process", - "gpu-program-cache-size-kb", - "gpu-rasterization-msaa-sample-count", - "gpu-sandbox-allow-sysv-shm", - "gpu-sandbox-failures-fatal", - "gpu-sandbox-start-early", - "gpu-secondary-device-ids", - "gpu-secondary-vendor-ids", - "gpu-startup-dialog", - "gpu-testing-device-id", - "gpu-testing-driver-date", - "gpu-testing-gl-renderer", - "gpu-testing-gl-vendor", - "gpu-testing-gl-version", - "gpu-testing-os-version", - "gpu-testing-secondary-device-ids", - "gpu-testing-secondary-vendor-ids", - "gpu-testing-vendor-id", - "gpu-vendor-id", - "graphics-buffer-count", - "guest-wallpaper-large", - "guest-wallpaper-small", - "h", - "has-chromeos-diamond-key", - "has-chromeos-keyboard", - "has-internal-stylus", - "headless", - "help", - "hide", - "hide-icons", - "hide-scrollbars", - "history-entry-requires-user-gesture", - "homedir", - "homepage", - "host", - "host-pairing-oobe", - "host-resolver-rules", - "icu-data-dir", - "ignore-autocomplete-off-autofill", - "ignore-autoplay-restrictions", - "ignore-certificate-errors", - "ignore-certificate-errors-spki-list", - "ignore-gpu-blacklist", - "ignore-urlfetcher-cert-requests", - "ignore-user-profile-mapping-for-tests", - "in-process-gpu", - "incognito", - "input", - "inspect", - "inspect-brk", - "install-chrome-app", - "install-supervised-user-whitelists", - "instant-process", - "invalidation-use-gcm-channel", - "ipc-connection-timeout", - "ipc-dump-directory", - "ipc-fuzzer-testcase", - "is-running-in-mash", - "isolate-origins", - "isolate-sites-for-testing", - "javascript-harmony", - "js-flags", - "keep-alive-for-test", - "kiosk", - "kiosk-printing", - "lang", - "last-launched-app", - "layer", - "light_muted", - "light_vibrant", - "limit-fps", - "load-and-launch-app", - "load-apps", - "load-extension", - "load-media-router-component-extension", - "local-heuristics-only-for-password-generation", - "local-ntp-reload", - "local-sync-backend-dir", - "log-gpu-control-list-decisions", - "log-level", - "log-net-log", - "login-manager", - "login-profile", - "login-user", - "loopback-i2s-bits", - "loopback-i2s-bus-name", - "loopback-i2s-channels", - "loopback-i2s-rate-hz", - "lso-url", - "ltr", - "main-frame-resizes-are-orientation-changes", - "make-chrome-default", - "make-default-browser", - "managed-user-id", - "managed-user-sync-token", - "mark-non-secure-as", - "markdown", - "market-url-for-testing", - "mash", - "material", - "material-design-ink-drop-animation-speed", - "material-hybrid", - "max-gum-fps", - "max-output-volume-dba1m", - "max-untiled-layer-height", - "max-untiled-layer-width", - "media-cache-size", - "mem-pressure-system-reserved-kb", - "memlog", - "memory-pressure-off", - "memory-pressure-thresholds", - "memory-pressure-thresholds-mb", - "message-center-changes-while-open", - "method", - "metrics-client-id", - "metrics-recording-only", - "mhtml-generator-option", - "mirror", - "mock", - "mojo-local-storage", - "mojo-pipe-token", - "monitoring-destination-id", - "mse-audio-buffer-size-limit", - "mse-video-buffer-size-limit", - "mus", - "mus-config", - "mute-audio", - "nacl-broker", - "nacl-dangerous-no-sandbox-nonsfi", - "nacl-debug-mask", - "nacl-gdb", - "nacl-gdb-script", - "nacl-loader", - "nacl-loader-nonsfi", - "native", - "native-crx-bindings", - "need-arc-migration-policy-check", - "net-log-capture-mode", - "netifs-to-ignore", - "network-country-iso", - "network-settings-config", - "new-window", - "no-default-browser-check", - "no-experiments", - "no-first-run", - "no-managed-user-acknowledgment-check", - "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-secure", - "non-secure-after-editing", - "non-secure-while-incognito", - "non-secure-while-incognito-or-editing", - "none", - "normal_muted", - "normal_vibrant", - "note-taking-app-ids", - "ntp-snippets-add-incomplete", - "null", - "num-raster-threads", - "oauth2-client-id", - "oauth2-client-secret", - "off", - "on", - "oobe-bootstrapping-master", - "oobe-force-show-screen", - "oobe-guest-session", - "oobe-skip-postlogin", - "oobe-timer-interval", - "open-ash", - "opengraph", - "origin-trial-disabled-features", - "origin-trial-disabled-tokens", - "origin-trial-public-key", - "original-process-start-time", - "osmesa", - "output", - "override", - "override-metrics-upload-url", - "override-plugin-power-saver-for-testing", - "override-use-software-gl-for-tests", - "overscroll-history-navigation", - "overscroll-start-threshold", - "ozone-dump-file", - "ozone-platform", - "pack-extension", - "pack-extension-key", - "parent-profile", - "parent-window", - "passive-listeners-default", - "password-store", - "permission-request-api-scope", - "permission-request-api-url", - "ppapi", - "ppapi-antialiased-text-enabled", - "ppapi-broker", - "ppapi-flash-args", - "ppapi-flash-path", - "ppapi-flash-version", - "ppapi-in-process", - "ppapi-plugin-launcher", - "ppapi-startup-dialog", - "ppapi-subpixel-rendering-setting", - "previous-app", - "primary", - "print-to-pdf", - "privet-ipv6-only", - "process-per-site", - "process-per-tab", - "product-version", - "profile-directory", - "profiler-timing", - "profiling-at-start", - "profiling-file", - "profiling-flush", - "progress-bar-animation", - "progress-bar-completion", - "prompt-for-external-extensions", - "proxy-auto-detect", - "proxy-bypass-list", - "proxy-pac-url", - "proxy-server", - "pull-to-refresh", - "q", - "rdp_desktop_session", - "reader-mode-feedback", - "reader-mode-heuristics", - "rebaseline-pixel-tests", - "record-type", - "reduce-security-for-testing", - "reduced-referrer-granularity", - "register-font-files", - "register-pepper-plugins", - "relauncher", - "remote-debugging-address", - "remote-debugging-port", - "remote-debugging-socket-fd", - "remote-debugging-socket-name", - "remote-debugging-targets", - "renderer", - "renderer-client-id", - "renderer-cmd-prefix", - "renderer-process-limit", - "renderer-startup-dialog", - "renderer-wait-for-java-debugger", - "renderpass", - "repl", - "report-vp9-as-an-unsupported-mime-type", - "require-audio-hardware-for-testing", - "reset-app-list-install-state", - "reset-variation-state", - "restore-last-session", - "root", - "root-layer-scrolls", - "rtl", - "run-all-compositor-stages-before-draw", - "run-layout-test", - "runtime-deps-list-file", - "safebrowsing-disable-auto-update", - "safebrowsing-disable-download-protection", - "safebrowsing-disable-extension-blacklist", - "safebrowsing-manual-download-blacklist", - "sandbox-ipc", - "save-page-as-mhtml", - "screen-config", - "screenshot", - "script-executable", - "scripts-require-action", - "search-provider-logo-url", - "secondary", - "secondary-display-layout", - "secondary-ui-md", - "service", - "service-manager", - "service-name", - "service-pipe-token", - "service-request-channel-token", - "service-runner", - "shared-files", - "shill-stub", - "show-app-list", - "show-autofill-signatures", - "show-autofill-type-predictions", - "show-cert-link", - "show-component-extension-options", - "show-composited-layer-borders", - "show-fps-counter", - "show-icons", - "show-layer-animation-bounds", - "show-login-dev-overlay", - "show-mac-overlay-borders", - "show-md-login", - "show-non-md-login", - "show-overdraw-feedback", - "show-paint-rects", - "show-property-changed-rects", - "show-saved-copy", - "show-screenspace-rects", - "show-surface-damage-rects", - "silent-debugger-extension-api", - "silent-launch", - "simulate-critical-update", - "simulate-elevated-recovery", - "simulate-outdated", - "simulate-outdated-no-au", - "simulate-upgrade", - "single-process", - "site-per-process", - "skip-gpu-data-loading", - "skip-nostore-all", - "skip-nostore-main", - "skip-reencoding-on-skp-capture", - "slow", - "slow-connections-only", - "slow-down-compositing-scale-factor", - "slow-down-raster-scale-factor", - "sms-test-messages", - "spdy-proxy-auth-fallback", - "spdy-proxy-auth-origin", - "spdy-proxy-auth-value", - "spelling-service-feedback-interval-seconds", - "spelling-service-feedback-url", - "spurious-power-button-accel-count", - "spurious-power-button-keyboard-accel", - "spurious-power-button-lid-angle-change", - "spurious-power-button-screen-accel", - "spurious-power-button-window", - "ssl-key-log-file", - "ssl-version-max", - "ssl-version-min", - "stable-release-mode", - "start-fullscreen", - "start-maximized", - "start-stack-profiler", - "started", - "stub", - "stub-cros-settings", - "surface", - "swiftshader", - "swiftshader-webgl", - "sync-allow-insecure-xmpp-connection", - "sync-deferred-startup-timeout-seconds", - "sync-disable-deferred-startup", - "sync-enable-get-update-avoidance", - "sync-notification-host-port", - "sync-on-draw-hardware", - "sync-short-initial-retry-override", - "sync-short-nudge-delay-for-test", - "sync-url", - "system-developer-mode", - "system-log-upload-frequency", - "tab-management-experiment-type-disabled", - "tab-management-experiment-type-elderberry", - "task-manager-show-extra-renderers", - "task-profiler", - "team-drives", - "test-auto-update-ui", - "test-child-process", - "test-cros-gaia-id-migration", - "test-do-not-initialize-icu", - "test-encryption-migration-ui", - "test-gl-lib", - "test-launcher-batch-limit", - "test-launcher-bot-mode", - "test-launcher-debug-launcher", - "test-launcher-filter-file", - "test-launcher-force-run-broken-tests", - "test-launcher-jobs", - "test-launcher-list-tests", - "test-launcher-output", - "test-launcher-print-test-stdio", - "test-launcher-print-writable-path", - "test-launcher-retry-limit", - "test-launcher-shard-index", - "test-launcher-summary-output", - "test-launcher-test-part-results-limit", - "test-launcher-timeout", - "test-launcher-total-shards", - "test-launcher-trace", - "test-name", - "test-tiny-timeout", - "test-type", - "testing-fixed-http-port", - "testing-fixed-https-port", - "tether-stub", - "third-party-doodle-url", - "threads", - "time", - "timeout", - "tls1", - "tls1.1", - "tls1.2", - "tls1.3", - "tls13-variant", - "top-chrome-md", - "top-controls-hide-threshold", - "top-controls-show-threshold", - "touch-calibration", - "touch-devices", - "touch-events", - "touch-noise-filtering", - "touch-selection-strategy", - "touch_view", - "trace-config-file", - "trace-export-events-to-etw", - "trace-shutdown", - "trace-shutdown-file", - "trace-startup", - "trace-startup-duration", - "trace-startup-file", - "trace-to-console", - "trace-to-file", - "trace-to-file-name", - "trace-upload-url", - "tracelog", - "translate-ranker-model-url", - "translate-script-url", - "translate-security-origin", - "true", - "trusted-download-sources", - "try-chrome-again", - "try-supported-channel-layouts", - "type", - "ui-disable-partial-swap", - "ui-enable-layer-lists", - "ui-enable-rgba-4444-textures", - "ui-enable-zero-copy", - "ui-prioritize-in-gpu-process", - "ui-show-composited-layer-borders", - "ui-show-fps-counter", - "ui-show-layer-animation-bounds", - "ui-show-paint-rects", - "ui-show-property-changed-rects", - "ui-show-screenspace-rects", - "ui-show-surface-damage-rects", - "ui-slow-animations", - "ui-test-action-max-timeout", - "ui-test-action-timeout", - "uninstall", - "unlimited-storage", - "unsafe-pac-url", - "unsafely-allow-protected-media-identifier-for-domain", - "unsafely-treat-insecure-origin-as-secure", - "use-angle", - "use-cras", - "use-fake-device-for-media-stream", - "use-fake-jpeg-decode-accelerator", - "use-fake-ui-for-media-stream", - "use-file-for-fake-audio-capture", - "use-file-for-fake-video-capture", - "use-first-display-as-internal", - "use-gl", - "use-gpu-in-tests", - "use-ime-service", - "use-mobile-user-agent", - "use-mock-keychain", - "use-passthrough-cmd-decoder", - "use-skia-renderer", - "use-system-default-printer", - "use-test-config", - "use-viz-hit-test", - "user-agent", - "user-always-affiliated", - "user-data-dir", - "user-gesture-required", - "user-gesture-required-for-cross-origin", - "utility", - "utility-allowed-dir", - "utility-cmd-prefix", - "utility-run-elevated", - "utility-sandbox-type", - "utility-startup-dialog", - "v", - "v2-sandbox", - "v2-sandbox-enabled", - "v8-cache-options", - "v8-cache-strategies-for-cache-storage", - "validate-crx", - "validate-input-event-stream", - "variations-override-country", - "variations-server-url", - "version", - "video-image-texture-target", - "video-threads", - "video-underflow-threshold-ms", - "virtual-time-budget", - "vmodule", - "voice-interaction-supported-locales", - "wait-for-debugger", - "wait-for-debugger-children", - "wake-on-wifi-packet", - "wallet-service-use-sandbox", - "watcher", - "waveout-buffers", - "webapk-server-url", - "webrtc-stun-probe-trial", - "webview-enable-safebrowsing-support", - "webview-sandboxed-renderer", - "whitelisted-extension-id", - "win-jumplist-action", - "window-position", - "window-size", - "window-workspace", - "windows10-custom-titlebar", - "winhttp-proxy-resolver", - "wm-window-animations-disabled", - "yield-between-content-script-runs", - "zygote", - "zygote-cmd-prefix", + "/prefetch:1", + "/prefetch:2", + "/prefetch:3", + "/prefetch:4", + "/prefetch:5", + "/prefetch:6", + "/prefetch:8", + "0", + "?", + "ChromeOSMemoryPressureHandling", + "SafeSites", + "accept-resource-provider", + "account-consistency", + "adaboost", + "aec-refined-adaptive-filter", + "agc-startup-min-volume", + "aggressive", + "aggressive-cache-discard", + "aggressive-tab-discard", + "all", + "all-toolchains", + "allarticles", + "allow-cross-origin-auth-prompt", + "allow-external-pages", + "allow-failed-policy-fetch-for-test", + "allow-file-access-from-files", + "allow-hidden-media-playback", + "allow-http-background-page", + "allow-http-screen-capture", + "allow-insecure-localhost", + "allow-legacy-extension-manifests", + "allow-loopback-in-peer-connection", + "allow-nacl-crxfs-api", + "allow-nacl-file-handle-api", + "allow-nacl-socket-api", + "allow-no-sandbox-job", + "allow-outdated-plugins", + "allow-ra-in-dev-mode", + "allow-running-insecure-content", + "allow-sandbox-debugging", + "allow-silent-push", + "alsa-check-close-timeout", + "alsa-enable-upsampling", + "alsa-fixed-output-sample-rate", + "alsa-input-device", + "alsa-mute-device-name", + "alsa-mute-element-name", + "alsa-output-avail-min", + "alsa-output-buffer-size", + "alsa-output-device", + "alsa-output-period-size", + "alsa-output-start-threshold", + "alsa-volume-device-name", + "alsa-volume-element-name", + "also-emit-success-logs", + "alternative", + "always-authorize-plugins", + "always-on", + "always-use-complex-text", + "alwaystrue", + "amd-switchable", + "android-fonts-path", + "android-stderr-port", + "android-stdin-port", + "android-stdout-port", + "angle", + "app", + "app-auto-launched", + "app-id", + "app-mode-auth-code", + "app-mode-oauth-token", + "app-mode-oem-manifest", + "app-shell-allow-roaming", + "app-shell-host-window-size", + "app-shell-preferred-network", + "app-shell-refresh-token", + "app-shell-user", + "apple", + "apps-gallery-download-url", + "apps-gallery-update-url", + "apps-gallery-url", + "apps-keep-chrome-alive-in-tests", + "arc-availability", + "arc-available", + "arc-start-mode", + "arc-transition-migration-required", + "args", + "artifacts-dir", + "ash-constrain-pointer-to-root", + "ash-debug-shortcuts", + "ash-dev-shortcuts", + "ash-disable-smooth-screen-rotation", + "ash-disable-tablet-autohide-titlebars", + "ash-disable-touch-exploration-mode", + "ash-enable-magnifier-key-scroller", + "ash-enable-mirrored-screen", + "ash-enable-night-light", + "ash-enable-palette-on-all-displays", + "ash-enable-scale-settings-tray", + "ash-enable-software-mirroring", + "ash-enable-unified-desktop", + "ash-estimated-presentation-delay", + "ash-hide-notifications-for-factory", + "ash-host-window-bounds", + "ash-shelf-color", + "ash-shelf-color-scheme", + "ash-touch-hud", + "ash-webui-init", + "attestation-server", + "audio-buffer-size", + "audio-output-channels", + "aura-legacy-power-button", + "auth-ext-path", + "auth-server-whitelist", + "auth-spnego-account-type", + "auto", + "auto-open-devtools-for-tabs", + "auto-select-desktop-capture-source", + "autoplay-policy", + "blink-settings", + "bootstrap", + "browser", + "browser-startup-dialog", + "browser-subprocess-path", + "browser-test", + "bwsi", + "bypass-app-banner-engagement-checks", + "canvas-msaa-sample-count", + "cast-initial-screen-height", + "cast-initial-screen-width", + "cc-layer-tree-test-long-timeout", + "cc-layer-tree-test-no-timeout", + "cc-rebaseline-pixeltests", + "cellular-first", + "cellular-only", + "check-for-update-interval", + "check-layout-test-sys-deps", + "child-wallpaper-large", + "child-wallpaper-small", + "chrome-home-swipe-logic", + "cipher-suite-blacklist", + "clamshell", + "class", + "clear-token-service", + "cloud-print-file", + "cloud-print-file-type", + "cloud-print-job-title", + "cloud-print-print-ticket", + "cloud-print-setup-proxy", + "cloud-print-url", + "cloud-print-xmpp-endpoint", + "color", + "compensate-for-unstable-pinch-zoom", + "compile-shader-always-succeeds", + "component-updater", + "connectivity-check-url", + "conservative", + "content-image-texture-target", + "content-shell-host-window-size", + "controller", + "crash-dumps-dir", + "crash-on-failure", + "crash-on-hang-threads", + "crash-server-url", + "crash-test", + "crashpad-handler", + "create-browser-on-startup-for-tests", + "cros-gaia-api-v1", + "cros-region", + "cros-regions-mode", + "crosh-command", + "cryptauth-http-host", + "custom-devtools-frontend", + "custom-launcher-page", + "custom_summary", + "d3d-support", + "d3d11", + "d3d9", + "daemon", + "dark_muted", + "dark_vibrant", + "data-path", + "data-reduction-proxy-config-url", + "data-reduction-proxy-experiment", + "data-reduction-proxy-http-proxies", + "data-reduction-proxy-lo-fi", + "data-reduction-proxy-pingback-url", + "data-reduction-proxy-secure-proxy-check-url", + "data-reduction-proxy-server-experiments-disabled", + "dbus-stub", + "debug-devtools", + "debug-enable-frame-toggle", + "debug-packed-apps", + "debug-print", + "default", + "default-background-color", + "default-tile-height", + "default-tile-width", + "default-wallpaper-is-oem", + "default-wallpaper-large", + "default-wallpaper-small", + "demo", + "derelict-detection-timeout", + "derelict-idle-timeout", + "desktop", + "desktop-window-1080p", + "deterministic-fetch", + "device-management-url", + "device-scale-factor", + "devtools-flags", + "diagnostics", + "diagnostics-format", + "diagnostics-recovery", + "dice", + "dice_fix_auth_errors", + "disable", + "disable-2d-canvas-clip-aa", + "disable-2d-canvas-image-chromium", + "disable-3d-apis", + "disable-accelerated-2d-canvas", + "disable-accelerated-jpeg-decoding", + "disable-accelerated-mjpeg-decode", + "disable-accelerated-video-decode", + "disable-app-info-dialog-mac", + "disable-app-list-dismiss-on-blur", + "disable-app-window-cycling", + "disable-appcontainer", + "disable-arc-data-wipe", + "disable-arc-opt-in-verification", + "disable-audio-support-for-desktop-share", + "disable-avfoundation-overlays", + "disable-background-networking", + "disable-background-timer-throttling", + "disable-backgrounding-occluded-windows", + "disable-backing-store-limit", + "disable-blink-features", + "disable-boot-animation", + "disable-breakpad", + "disable-browser-task-scheduler", + "disable-bundled-ppapi-flash", + "disable-canvas-aa", + "disable-captive-portal-bypass-proxy", + "disable-cast-streaming-hw-encoding", + "disable-checker-imaging", + "disable-clear-browsing-data-counters", + "disable-client-side-phishing-detection", + "disable-cloud-import", + "disable-component-cloud-policy", + "disable-component-extensions-with-background-pages", + "disable-component-update", + "disable-composited-antialiasing", + "disable-contextual-search", + "disable-d3d11", + "disable-databases", + "disable-datasaver-prompt", + "disable-default-apps", + "disable-demo-mode", + "disable-device-disabling", + "disable-device-discovery-notifications", + "disable-dinosaur-easter-egg", + "disable-direct-composition", + "disable-direct-composition-layers", + "disable-directwrite-for-ui", + "disable-display-list-2d-canvas", + "disable-distance-field-text", + "disable-domain-blocking-for-3d-apis", + "disable-domain-reliability", + "disable-drive-search-in-app-launcher", + "disable-dwm-composition", + "disable-encryption-migration", + "disable-eol-notification", + "disable-es3-apis", + "disable-es3-gl-context", + "disable-extensions", + "disable-extensions-except", + "disable-extensions-file-access-check", + "disable-extensions-http-throttling", + "disable-features", + "disable-field-trial-config", + "disable-file-manager-touch-mode", + "disable-file-system", + "disable-flash-3d", + "disable-flash-stage3d", + "disable-fullscreen-low-power-mode", + "disable-fullscreen-tab-detaching", + "disable-gaia-services", + "disable-gesture-editing", + "disable-gesture-requirement-for-presentation", + "disable-gesture-typing", + "disable-gl-drawing-for-tests", + "disable-gl-error-limit", + "disable-gl-extensions", + "disable-glsl-translator", + "disable-gpu", + "disable-gpu-compositing", + "disable-gpu-driver-bug-workarounds", + "disable-gpu-early-init", + "disable-gpu-memory-buffer-compositor-resources", + "disable-gpu-memory-buffer-video-frames", + "disable-gpu-process-crash-limit", + "disable-gpu-program-cache", + "disable-gpu-rasterization", + "disable-gpu-sandbox", + "disable-gpu-shader-disk-cache", + "disable-gpu-vsync", + "disable-gpu-watchdog", + "disable-hang-monitor", + "disable-hid-detection-on-oobe", + "disable-histogram-customizer", + "disable-hosted-app-shim-creation", + "disable-hosted-apps-in-windows", + "disable-in-process-stack-traces", + "disable-infobars", + "disable-input-ime-api", + "disable-input-view", + "disable-ios-password-suggestions", + "disable-javascript-harmony-shipping", + "disable-kill-after-bad-ipc", + "disable-lcd-text", + "disable-legacy-window", + "disable-local-storage", + "disable-lock-screen-apps", + "disable-logging", + "disable-logging-redirect", + "disable-login-animations", + "disable-login-screen-apps", + "disable-low-end-device-mode", + "disable-low-latency-dxva", + "disable-low-res-tiling", + "disable-mac-overlays", + "disable-mac-views-native-app-windows", + "disable-machine-cert-request", + "disable-main-frame-before-activation", + "disable-md-error-screen", + "disable-md-oobe", + "disable-media-session-api", + "disable-media-suspend", + "disable-merge-key-char-events", + "disable-mojo-local-storage", + "disable-mojo-renderer", + "disable-mtp-write-support", + "disable-multi-display-layout", + "disable-namespace-sandbox", + "disable-native-gpu-memory-buffers", + "disable-network-portal-notification", + "disable-new-korean-ime", + "disable-new-virtual-keyboard-behavior", + "disable-new-zip-unpacker", + "disable-notifications", + "disable-ntp-most-likely-favicons-from-server", + "disable-ntp-popular-sites", + "disable-nv12-dxgi-video", + "disable-offer-store-unmasked-wallet-cards", + "disable-offer-upload-credit-cards", + "disable-office-editing-component-extension", + "disable-offline-auto-reload", + "disable-offline-auto-reload-visible-only", + "disable-origin-trial-controlled-blink-features", + "disable-overscroll-edge-effect", + "disable-panel-fitting", + "disable-partial-raster", + "disable-password-generation", + "disable-pepper-3d", + "disable-pepper-3d-image-chromium", + "disable-per-user-timezone", + "disable-permission-action-reporting", + "disable-permissions-api", + "disable-physical-keyboard-autocorrect", + "disable-pinch", + "disable-pnacl-crash-throttling", + "disable-popup-blocking", + "disable-prefer-compositing-to-lcd-text", + "disable-presentation-api", + "disable-print-preview", + "disable-prompt-on-repost", + "disable-proximity-auth-bluetooth-low-energy-discovery", + "disable-pull-to-refresh-effect", + "disable-push-api-background-mode", + "disable-reading-from-canvas", + "disable-remote-core-animation", + "disable-remote-fonts", + "disable-remote-playback-api", + "disable-renderer-accessibility", + "disable-renderer-backgrounding", + "disable-resize-lock", + "disable-rgba-4444-textures", + "disable-rollback-option", + "disable-rtc-smoothness-algorithm", + "disable-screen-orientation-lock", + "disable-search-geolocation-disclosure", + "disable-seccomp-filter-sandbox", + "disable-setuid-sandbox", + "disable-shader-name-hashing", + "disable-shared-workers", + "disable-signin-promo", + "disable-signin-scoped-device-id", + "disable-single-click-autofill", + "disable-skia-runtime-opts", + "disable-slim-navigation-manager", + "disable-slimming-paint-invalidation", + "disable-smooth-scrolling", + "disable-software-rasterizer", + "disable-speech-api", + "disable-suggestions-ui", + "disable-surface-references", + "disable-sync", + "disable-sync-app-list", + "disable-sync-types", + "disable-system-timezone-automatic-detection", + "disable-tab-for-desktop-share", + "disable-third-party-keyboard-workaround", + "disable-threaded-animation", + "disable-threaded-compositing", + "disable-threaded-scrolling", + "disable-timeouts-for-profiling", + "disable-touch-adjustment", + "disable-touch-drag-drop", + "disable-translate-new-ux", + "disable-usb-keyboard-detect", + "disable-v8-idle-tasks", + "disable-vaapi-accelerated-video-encode", + "disable-virtual-keyboard-overscroll", + "disable-voice-input", + "disable-volume-adjust-sound", + "disable-wake-on-wifi", + "disable-web-notification-custom-layouts", + "disable-web-security", + "disable-webgl", + "disable-webgl-image-chromium", + "disable-webrtc-encryption", + "disable-webrtc-hw-decoding", + "disable-webrtc-hw-encoding", + "disable-win32k-lockdown", + "disable-xss-auditor", + "disable-zero-browsers-open-for-tests", + "disable-zero-copy", + "disable-zero-copy-dxgi-video", + "disabled", + "disabled-new-style-notification", + "disallow-non-exact-resource-reuse", + "disk-cache-dir", + "disk-cache-size", + "display", + "dmg-device", + "dns-log-details", + "document-user-activation-required", + "dom-automation", + "dotfile", + "draft", + "draw-view-bounds-rects", + "duck-flash", + "dump-blink-runtime-call-stats", + "dump-browser-histograms", + "dump-dom", + "eafe-path", + "eafe-url", + "easy-unlock-app-path", + "edge-touch-filtering", + "egl", + "elevate", + "embedded-extension-options", + "emphasize-titles-in-omnibox-dropdown", + "emulate-shader-precision", + "enable-accelerated-2d-canvas", + "enable-accelerated-vpx-decode", + "enable-accessibility-tab-switcher", + "enable-adaptive-selection-handle-orientation", + "enable-aggressive-domstorage-flushing", + "enable-android-wallpapers-app", + "enable-app-info-dialog-mac", + "enable-app-list", + "enable-app-window-cycling", + "enable-appcontainer", + "enable-arc", + "enable-arc-oobe-optin", + "enable-async-event-targeting", + "enable-audio-debug-recordings-from-extension", + "enable-audio-focus", + "enable-automation", + "enable-background-fetch-persistence", + "enable-benchmarking", + "enable-ble-advertising-in-apps", + "enable-blink-features", + "enable-bookmark-undo", + "enable-browser-side-navigation", + "enable-browser-task-scheduler", + "enable-cast-receiver", + "enable-checker-imaging", + "enable-chromevox-arc-support", + "enable-clear-browsing-data-counters", + "enable-cloud-print-proxy", + "enable-cloud-print-xps", + "enable-consumer-kiosk", + "enable-contextual-search", + "enable-crash-reporter", + "enable-crash-reporter-for-testing", + "enable-crx-hash-check", + "enable-data-reduction-proxy-bypass-warning", + "enable-data-reduction-proxy-force-pingback", + "enable-data-reduction-proxy-lite-page", + "enable-data-reduction-proxy-savings-promo", + "enable-datasaver-prompt", + "enable-device-discovery-notifications", + "enable-devtools-experiments", + "enable-direct-composition-layers", + "enable-display-list-2d-canvas", + "enable-distance-field-text", + "enable-distillability-service", + "enable-dom-distiller", + "enable-domain-reliability", + "enable-drive-search-in-app-launcher", + "enable-drm-atomic", + "enable-embedded-extension-options", + "enable-encryption-migration", + "enable-encryption-selection", + "enable-es3-apis", + "enable-exclusive-audio", + "enable-experimental-accessibility-features", + "enable-experimental-canvas-features", + "enable-experimental-extension-apis", + "enable-experimental-fullscreen-exit-ui", + "enable-experimental-input-view-features", + "enable-experimental-web-platform-features", + "enable-extension-activity-log-testing", + "enable-extension-activity-logging", + "enable-extension-assets-sharing", + "enable-external-drive-rename", + "enable-fast-unload", + "enable-features", + "enable-file-manager-touch-mode", + "enable-first-run-ui-transitions", + "enable-floating-virtual-keyboard", + "enable-font-antialiasing", + "enable-fullscreen-tab-detaching", + "enable-fullscreen-toolbar-reveal", + "enable-google-branded-context-menu", + "enable-gpu-async-worker-context", + "enable-gpu-benchmarking", + "enable-gpu-client-logging", + "enable-gpu-client-tracing", + "enable-gpu-command-logging", + "enable-gpu-debugging", + "enable-gpu-driver-debug-logging", + "enable-gpu-memory-buffer-compositor-resources", + "enable-gpu-memory-buffer-video-frames", + "enable-gpu-rasterization", + "enable-gpu-service-logging", + "enable-gpu-service-tracing", + "enable-hardware-overlays", + "enable-harfbuzz-rendertext", + "enable-heap-profiling", + "enable-hosted-app-quit-notification", + "enable-hosted-apps-in-windows", + "enable-hotword-hardware", + "enable-hung-renderer-infobar", + "enable-inband-text-tracks", + "enable-input-ime-api", + "enable-instant-tethering", + "enable-internal-media-session", + "enable-ios-handoff-to-other-devices", + "enable-layer-lists", + "enable-lcd-text", + "enable-leak-detection", + "enable-local-file-accesses", + "enable-local-sync-backend", + "enable-logging", + "enable-longpress-drag-selection", + "enable-low-end-device-mode", + "enable-low-res-tiling", + "enable-mac-views-native-app-windows", + "enable-main-frame-before-activation", + "enable-md-feedback", + "enable-media-suspend", + "enable-merge-key-char-events", + "enable-message-center-always-scroll-up-upon-notification-removal", + "enable-nacl", + "enable-nacl-debug", + "enable-nacl-nonsfi-mode", + "enable-native-gpu-memory-buffers", + "enable-natural-scroll-default", + "enable-navigation-tracing", + "enable-net-benchmarking", + "enable-network-information-downlink-max", + "enable-network-portal-notification", + "enable-new-app-menu-icon", + "enable-ntp-most-likely-favicons-from-server", + "enable-ntp-popular-sites", + "enable-ntp-search-engine-country-detection", + "enable-offer-store-unmasked-wallet-cards", + "enable-offer-upload-credit-cards", + "enable-offline-auto-reload", + "enable-offline-auto-reload-visible-only", + "enable-oop-rasterization", + "enable-osk-overscroll", + "enable-override-bookmarks-ui", + "enable-partial-raster", + "enable-password-generation", + "enable-pepper-testing", + "enable-permission-action-reporting", + "enable-physical-keyboard-autocorrect", + "enable-picture-in-picture", + "enable-pinch", + "enable-pixel-canvas-recording", + "enable-pixel-output-in-tests", + "enable-plugin-placeholder-testing", + "enable-potentially-annoying-security-features", + "enable-power-overlay", + "enable-precise-memory-info", + "enable-prefer-compositing-to-lcd-text", + "enable-print-browser", + "enable-print-preview-register-promos", + "enable-profile-shortcut-manager", + "enable-profiling", + "enable-push-api-background-mode", + "enable-refresh-token-annotation-request", + "enable-request-tablet-site", + "enable-rgba-4444-textures", + "enable-sandbox", + "enable-sandbox-logging", + "enable-screenshot-testing-with-mode", + "enable-scripts-require-action", + "enable-scroll-prediction", + "enable-service-manager-tracing", + "enable-sgi-video-sync", + "enable-signin-promo", + "enable-single-click-autofill", + "enable-site-settings", + "enable-skia-benchmarking", + "enable-slim-navigation-manager", + "enable-slimming-paint-invalidation", + "enable-slimming-paint-v2", + "enable-smooth-scrolling", + "enable-spatial-navigation", + "enable-spdy-proxy-auth", + "enable-speech-dispatcher", + "enable-spelling-feedback-field-trial", + "enable-spotlight-actions", + "enable-stats-collection-bindings", + "enable-stats-table", + "enable-strict-mixed-content-checking", + "enable-strict-powerful-feature-restrictions", + "enable-suggestions-ui", + "enable-suggestions-with-substring-match", + "enable-supervised-user-managed-bookmarks-folder", + "enable-surface-synchronization", + "enable-swap-buffers-with-bounds", + "enable-sync-app-list", + "enable-sync-articles", + "enable-tab-audio-muting", + "enable-tablet-splitview", + "enable-tcp-fastopen", + "enable-third-party-keyboard-workaround", + "enable-threaded-compositing", + "enable-threaded-texture-mailboxes", + "enable-tile-compression", + "enable-touch-calibration-setting", + "enable-touch-drag-drop", + "enable-touchpad-three-finger-click", + "enable-touchview", + "enable-trace-app-source", + "enable-tracing", + "enable-tracing-output", + "enable-translate-new-ux", + "enable-ui-devtools", + "enable-use-zoom-for-dsf", + "enable-user-metrics", + "enable-usermedia-screen-capturing", + "enable-video-player-chromecast-support", + "enable-viewport", + "enable-virtual-keyboard", + "enable-voice-interaction", + "enable-vtune-support", + "enable-vulkan", + "enable-wayland-server", + "enable-web-notification-custom-layouts", + "enable-webfonts-intervention-trigger", + "enable-webfonts-intervention-v2", + "enable-webgl-draft-extensions", + "enable-webgl-image-chromium", + "enable-webrtc-event-logging-from-extension", + "enable-webrtc-srtp-aes-gcm", + "enable-webrtc-srtp-encrypted-headers", + "enable-webrtc-stun-origin", + "enable-webview-variations", + "enable-webvr", + "enable-wifi-credential-sync", + "enable-win7-webrtc-hw-h264-decoding", + "enable-zero-copy", + "enable-zip-archiver-on-file-manager", + "enabled", + "enabled-2g", + "enabled-3g", + "enabled-new-style-notification", + "enabled-slow2g", + "encode-binary", + "enforce", + "enforce-gl-minimums", + "enforce-webrtc-ip-permission-check", + "enforce_strict", + "enterprise-disable-arc", + "enterprise-enable-forced-re-enrollment", + "enterprise-enable-license-type-selection", + "enterprise-enable-zero-touch-enrollment", + "enterprise-enrollment-initial-modulus", + "enterprise-enrollment-modulus-limit", + "error-console", + "evaluate-type", + "evaluate_capability", + "experiment", + "explicitly-allowed-ports", + "expose-internals-for-testing", + "extension-content-verification", + "extension-process", + "extensions-install-verification", + "extensions-multi-account", + "extensions-not-webstore", + "extensions-on-chrome-urls", + "extensions-update-frequency", + "extra-search-query-params", + "fail-on-unused-args", + "fake-variations-channel", + "false", + "fast", + "fast-start", + "feedback-server", + "field-trial-handle", + "first-exec-after-boot", + "flag-switches-begin", + "flag-switches-end", + "font-cache-shared-handle", + "force-android-app-mode", + "force-app-mode", + "force-clamshell-power-button", + "force-color-profile", + "force-desktop-ios-promotion", + "force-dev-mode-highlighting", + "force-device-scale-factor", + "force-display-list-2d-canvas", + "force-effective-connection-type", + "force-enable-metrics-reporting", + "force-enable-stylus-tools", + "force-fieldtrial-params", + "force-fieldtrials", + "force-first-run", + "force-first-run-ui", + "force-gpu-mem-available-mb", + "force-gpu-rasterization", + "force-happiness-tracking-system", + "force-load-easy-unlock-app-in-tests", + "force-local-ntp", + "force-login-manager-in-tests", + "force-mediafoundation", + "force-overlay-fullscreen-video", + "force-password-reauth", + "force-pnacl-subzero", + "force-presentation-receiver-for-testing", + "force-renderer-accessibility", + "force-show-update-menu-badge", + "force-show-update-menu-item", + "force-system-compositor-mode", + "force-tablet-mode", + "force-text-direction", + "force-ui-direction", + "force-variation-ids", + "force-video-overlays", + "force-wave-audio", + "force-webrtc-ip-handling-policy", + "full-memory-crash-report", + "gaia-url", + "gcm-checkin-url", + "gcm-mcs-endpoint", + "gcm-registration-url", + "generate-accessibility-test-expectations", + "gl", + "gl-composited-overlay-candidate-quad-border", + "gl-shader-interm-output", + "gles", + "golden-screenshots-dir", + "google-apis-url", + "google-base-url", + "google-doodle-url", + "google-url", + "gpu-active-device-id", + "gpu-active-vendor-id", + "gpu-device-id", + "gpu-driver-date", + "gpu-driver-vendor", + "gpu-driver-version", + "gpu-launcher", + "gpu-no-complete-info-collection", + "gpu-no-context-lost", + "gpu-process", + "gpu-program-cache-size-kb", + "gpu-rasterization-msaa-sample-count", + "gpu-sandbox-allow-sysv-shm", + "gpu-sandbox-failures-fatal", + "gpu-sandbox-start-early", + "gpu-secondary-device-ids", + "gpu-secondary-vendor-ids", + "gpu-startup-dialog", + "gpu-testing-device-id", + "gpu-testing-driver-date", + "gpu-testing-gl-renderer", + "gpu-testing-gl-vendor", + "gpu-testing-gl-version", + "gpu-testing-os-version", + "gpu-testing-secondary-device-ids", + "gpu-testing-secondary-vendor-ids", + "gpu-testing-vendor-id", + "gpu-vendor-id", + "graphics-buffer-count", + "guest-wallpaper-large", + "guest-wallpaper-small", + "h", + "has-chromeos-diamond-key", + "has-chromeos-keyboard", + "has-internal-stylus", + "headless", + "help", + "hide", + "hide-icons", + "hide-scrollbars", + "history-entry-requires-user-gesture", + "homedir", + "homepage", + "host", + "host-pairing-oobe", + "host-resolver-rules", + "icu-data-dir", + "ignore-autocomplete-off-autofill", + "ignore-autoplay-restrictions", + "ignore-certificate-errors", + "ignore-certificate-errors-spki-list", + "ignore-gpu-blacklist", + "ignore-urlfetcher-cert-requests", + "ignore-user-profile-mapping-for-tests", + "in-process-gpu", + "incognito", + "input", + "inspect", + "inspect-brk", + "install-chrome-app", + "install-supervised-user-whitelists", + "instant-process", + "invalidation-use-gcm-channel", + "ipc-connection-timeout", + "ipc-dump-directory", + "ipc-fuzzer-testcase", + "is-running-in-mash", + "isolate-origins", + "isolate-sites-for-testing", + "javascript-harmony", + "js-flags", + "keep-alive-for-test", + "kiosk", + "kiosk-printing", + "lang", + "last-launched-app", + "layer", + "light_muted", + "light_vibrant", + "limit-fps", + "load-and-launch-app", + "load-apps", + "load-extension", + "load-media-router-component-extension", + "local-heuristics-only-for-password-generation", + "local-ntp-reload", + "local-sync-backend-dir", + "log-gpu-control-list-decisions", + "log-level", + "log-net-log", + "login-manager", + "login-profile", + "login-user", + "loopback-i2s-bits", + "loopback-i2s-bus-name", + "loopback-i2s-channels", + "loopback-i2s-rate-hz", + "lso-url", + "ltr", + "main-frame-resizes-are-orientation-changes", + "make-chrome-default", + "make-default-browser", + "managed-user-id", + "managed-user-sync-token", + "mark-non-secure-as", + "markdown", + "market-url-for-testing", + "mash", + "material", + "material-design-ink-drop-animation-speed", + "material-hybrid", + "max-gum-fps", + "max-output-volume-dba1m", + "max-untiled-layer-height", + "max-untiled-layer-width", + "media-cache-size", + "mem-pressure-system-reserved-kb", + "memlog", + "memory-pressure-off", + "memory-pressure-thresholds", + "memory-pressure-thresholds-mb", + "message-center-changes-while-open", + "method", + "metrics-client-id", + "metrics-recording-only", + "mhtml-generator-option", + "mirror", + "mock", + "mojo-local-storage", + "mojo-pipe-token", + "monitoring-destination-id", + "mse-audio-buffer-size-limit", + "mse-video-buffer-size-limit", + "mus", + "mus-config", + "mute-audio", + "nacl-broker", + "nacl-dangerous-no-sandbox-nonsfi", + "nacl-debug-mask", + "nacl-gdb", + "nacl-gdb-script", + "nacl-loader", + "nacl-loader-nonsfi", + "native", + "native-crx-bindings", + "need-arc-migration-policy-check", + "net-log-capture-mode", + "netifs-to-ignore", + "network-country-iso", + "network-settings-config", + "new-window", + "no-default-browser-check", + "no-experiments", + "no-first-run", + "no-managed-user-acknowledgment-check", + "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-secure", + "non-secure-after-editing", + "non-secure-while-incognito", + "non-secure-while-incognito-or-editing", + "none", + "normal_muted", + "normal_vibrant", + "note-taking-app-ids", + "ntp-snippets-add-incomplete", + "null", + "num-raster-threads", + "oauth2-client-id", + "oauth2-client-secret", + "off", + "on", + "oobe-bootstrapping-master", + "oobe-force-show-screen", + "oobe-guest-session", + "oobe-skip-postlogin", + "oobe-timer-interval", + "open-ash", + "opengraph", + "origin-trial-disabled-features", + "origin-trial-disabled-tokens", + "origin-trial-public-key", + "original-process-start-time", + "osmesa", + "output", + "override", + "override-metrics-upload-url", + "override-plugin-power-saver-for-testing", + "override-use-software-gl-for-tests", + "overscroll-history-navigation", + "overscroll-start-threshold", + "ozone-dump-file", + "ozone-platform", + "pack-extension", + "pack-extension-key", + "parent-profile", + "parent-window", + "passive-listeners-default", + "password-store", + "permission-request-api-scope", + "permission-request-api-url", + "ppapi", + "ppapi-antialiased-text-enabled", + "ppapi-broker", + "ppapi-flash-args", + "ppapi-flash-path", + "ppapi-flash-version", + "ppapi-in-process", + "ppapi-plugin-launcher", + "ppapi-startup-dialog", + "ppapi-subpixel-rendering-setting", + "previous-app", + "primary", + "print-to-pdf", + "privet-ipv6-only", + "process-per-site", + "process-per-tab", + "product-version", + "profile-directory", + "profiler-timing", + "profiling-at-start", + "profiling-file", + "profiling-flush", + "progress-bar-animation", + "progress-bar-completion", + "prompt-for-external-extensions", + "proxy-auto-detect", + "proxy-bypass-list", + "proxy-pac-url", + "proxy-server", + "pull-to-refresh", + "q", + "rdp_desktop_session", + "reader-mode-feedback", + "reader-mode-heuristics", + "rebaseline-pixel-tests", + "record-type", + "reduce-security-for-testing", + "reduced-referrer-granularity", + "register-font-files", + "register-pepper-plugins", + "relauncher", + "remote-debugging-address", + "remote-debugging-port", + "remote-debugging-socket-fd", + "remote-debugging-socket-name", + "remote-debugging-targets", + "renderer", + "renderer-client-id", + "renderer-cmd-prefix", + "renderer-process-limit", + "renderer-startup-dialog", + "renderer-wait-for-java-debugger", + "renderpass", + "repl", + "report-vp9-as-an-unsupported-mime-type", + "require-audio-hardware-for-testing", + "reset-app-list-install-state", + "reset-variation-state", + "restore-last-session", + "root", + "root-layer-scrolls", + "rtl", + "run-all-compositor-stages-before-draw", + "run-layout-test", + "runtime-deps-list-file", + "safebrowsing-disable-auto-update", + "safebrowsing-disable-download-protection", + "safebrowsing-disable-extension-blacklist", + "safebrowsing-manual-download-blacklist", + "sandbox-ipc", + "save-page-as-mhtml", + "screen-config", + "screenshot", + "script-executable", + "scripts-require-action", + "search-provider-logo-url", + "secondary", + "secondary-display-layout", + "secondary-ui-md", + "service", + "service-manager", + "service-name", + "service-pipe-token", + "service-request-channel-token", + "service-runner", + "shared-files", + "shill-stub", + "show-app-list", + "show-autofill-signatures", + "show-autofill-type-predictions", + "show-cert-link", + "show-component-extension-options", + "show-composited-layer-borders", + "show-fps-counter", + "show-icons", + "show-layer-animation-bounds", + "show-login-dev-overlay", + "show-mac-overlay-borders", + "show-md-login", + "show-non-md-login", + "show-overdraw-feedback", + "show-paint-rects", + "show-property-changed-rects", + "show-saved-copy", + "show-screenspace-rects", + "show-surface-damage-rects", + "silent-debugger-extension-api", + "silent-launch", + "simulate-critical-update", + "simulate-elevated-recovery", + "simulate-outdated", + "simulate-outdated-no-au", + "simulate-upgrade", + "single-process", + "site-per-process", + "skip-gpu-data-loading", + "skip-nostore-all", + "skip-nostore-main", + "skip-reencoding-on-skp-capture", + "slow", + "slow-connections-only", + "slow-down-compositing-scale-factor", + "slow-down-raster-scale-factor", + "sms-test-messages", + "spdy-proxy-auth-fallback", + "spdy-proxy-auth-origin", + "spdy-proxy-auth-value", + "spelling-service-feedback-interval-seconds", + "spelling-service-feedback-url", + "spurious-power-button-accel-count", + "spurious-power-button-keyboard-accel", + "spurious-power-button-lid-angle-change", + "spurious-power-button-screen-accel", + "spurious-power-button-window", + "ssl-key-log-file", + "ssl-version-max", + "ssl-version-min", + "stable-release-mode", + "start-fullscreen", + "start-maximized", + "start-stack-profiler", + "started", + "stub", + "stub-cros-settings", + "surface", + "swiftshader", + "swiftshader-webgl", + "sync-allow-insecure-xmpp-connection", + "sync-deferred-startup-timeout-seconds", + "sync-disable-deferred-startup", + "sync-enable-get-update-avoidance", + "sync-notification-host-port", + "sync-on-draw-hardware", + "sync-short-initial-retry-override", + "sync-short-nudge-delay-for-test", + "sync-url", + "system-developer-mode", + "system-log-upload-frequency", + "tab-management-experiment-type-disabled", + "tab-management-experiment-type-elderberry", + "task-manager-show-extra-renderers", + "task-profiler", + "team-drives", + "test-auto-update-ui", + "test-child-process", + "test-cros-gaia-id-migration", + "test-do-not-initialize-icu", + "test-encryption-migration-ui", + "test-gl-lib", + "test-launcher-batch-limit", + "test-launcher-bot-mode", + "test-launcher-debug-launcher", + "test-launcher-filter-file", + "test-launcher-force-run-broken-tests", + "test-launcher-jobs", + "test-launcher-list-tests", + "test-launcher-output", + "test-launcher-print-test-stdio", + "test-launcher-print-writable-path", + "test-launcher-retry-limit", + "test-launcher-shard-index", + "test-launcher-summary-output", + "test-launcher-test-part-results-limit", + "test-launcher-timeout", + "test-launcher-total-shards", + "test-launcher-trace", + "test-name", + "test-tiny-timeout", + "test-type", + "testing-fixed-http-port", + "testing-fixed-https-port", + "tether-stub", + "third-party-doodle-url", + "threads", + "time", + "timeout", + "tls1", + "tls1.1", + "tls1.2", + "tls1.3", + "tls13-variant", + "top-chrome-md", + "top-controls-hide-threshold", + "top-controls-show-threshold", + "touch-calibration", + "touch-devices", + "touch-events", + "touch-noise-filtering", + "touch-selection-strategy", + "touch_view", + "trace-config-file", + "trace-export-events-to-etw", + "trace-shutdown", + "trace-shutdown-file", + "trace-startup", + "trace-startup-duration", + "trace-startup-file", + "trace-to-console", + "trace-to-file", + "trace-to-file-name", + "trace-upload-url", + "tracelog", + "translate-ranker-model-url", + "translate-script-url", + "translate-security-origin", + "true", + "trusted-download-sources", + "try-chrome-again", + "try-supported-channel-layouts", + "type", + "ui-disable-partial-swap", + "ui-enable-layer-lists", + "ui-enable-rgba-4444-textures", + "ui-enable-zero-copy", + "ui-prioritize-in-gpu-process", + "ui-show-composited-layer-borders", + "ui-show-fps-counter", + "ui-show-layer-animation-bounds", + "ui-show-paint-rects", + "ui-show-property-changed-rects", + "ui-show-screenspace-rects", + "ui-show-surface-damage-rects", + "ui-slow-animations", + "ui-test-action-max-timeout", + "ui-test-action-timeout", + "uninstall", + "unlimited-storage", + "unsafe-pac-url", + "unsafely-allow-protected-media-identifier-for-domain", + "unsafely-treat-insecure-origin-as-secure", + "use-angle", + "use-cras", + "use-fake-device-for-media-stream", + "use-fake-jpeg-decode-accelerator", + "use-fake-ui-for-media-stream", + "use-file-for-fake-audio-capture", + "use-file-for-fake-video-capture", + "use-first-display-as-internal", + "use-gl", + "use-gpu-in-tests", + "use-ime-service", + "use-mobile-user-agent", + "use-mock-keychain", + "use-passthrough-cmd-decoder", + "use-skia-renderer", + "use-system-default-printer", + "use-test-config", + "use-viz-hit-test", + "user-agent", + "user-always-affiliated", + "user-data-dir", + "user-gesture-required", + "user-gesture-required-for-cross-origin", + "utility", + "utility-allowed-dir", + "utility-cmd-prefix", + "utility-run-elevated", + "utility-sandbox-type", + "utility-startup-dialog", + "v", + "v2-sandbox", + "v2-sandbox-enabled", + "v8-cache-options", + "v8-cache-strategies-for-cache-storage", + "validate-crx", + "validate-input-event-stream", + "variations-override-country", + "variations-server-url", + "version", + "video-image-texture-target", + "video-threads", + "video-underflow-threshold-ms", + "virtual-time-budget", + "vmodule", + "voice-interaction-supported-locales", + "wait-for-debugger", + "wait-for-debugger-children", + "wake-on-wifi-packet", + "wallet-service-use-sandbox", + "watcher", + "waveout-buffers", + "webapk-server-url", + "webrtc-stun-probe-trial", + "webview-enable-safebrowsing-support", + "webview-sandboxed-renderer", + "whitelisted-extension-id", + "win-jumplist-action", + "window-position", + "window-size", + "window-workspace", + "windows10-custom-titlebar", + "winhttp-proxy-resolver", + "wm-window-animations-disabled", + "yield-between-content-script-runs", + "zygote", + "zygote-cmd-prefix", }; bool IsBlacklistedArg(const base::CommandLine::CharType* arg) { diff --git a/atom/app/command_line_args.h b/atom/app/command_line_args.h index 1f5fd756868..2c0acc1648f 100644 --- a/atom/app/command_line_args.h +++ b/atom/app/command_line_args.h @@ -14,4 +14,3 @@ bool CheckCommandLineArguments(int argc, base::CommandLine::CharType** argv); } // namespace atom #endif // ATOM_APP_COMMAND_LINE_ARGS_H_ - diff --git a/atom/app/node_main.cc b/atom/app/node_main.cc index 8e0089ad95c..61a661e4ad9 100644 --- a/atom/app/node_main.cc +++ b/atom/app/node_main.cc @@ -26,7 +26,7 @@ namespace atom { -int NodeMain(int argc, char *argv[]) { +int NodeMain(int argc, char* argv[]) { base::CommandLine::Init(argc, argv); int exit_code = 1; diff --git a/atom/app/node_main.h b/atom/app/node_main.h index e77bccbc1d7..68fe25f6df6 100644 --- a/atom/app/node_main.h +++ b/atom/app/node_main.h @@ -9,7 +9,7 @@ namespace atom { -int NodeMain(int argc, char *argv[]); +int NodeMain(int argc, char* argv[]); } // namespace atom diff --git a/atom/app/uv_task_runner.cc b/atom/app/uv_task_runner.cc index 7f998417c03..60befc6db8f 100644 --- a/atom/app/uv_task_runner.cc +++ b/atom/app/uv_task_runner.cc @@ -10,8 +10,7 @@ namespace atom { -UvTaskRunner::UvTaskRunner(uv_loop_t* loop) : loop_(loop) { -} +UvTaskRunner::UvTaskRunner(uv_loop_t* loop) : loop_(loop) {} UvTaskRunner::~UvTaskRunner() { for (auto& iter : tasks_) { @@ -35,10 +34,9 @@ bool UvTaskRunner::RunsTasksInCurrentSequence() const { return true; } -bool UvTaskRunner::PostNonNestableDelayedTask( - const base::Location& from_here, - base::OnceClosure task, - base::TimeDelta delay) { +bool UvTaskRunner::PostNonNestableDelayedTask(const base::Location& from_here, + base::OnceClosure task, + base::TimeDelta delay) { return PostDelayedTask(from_here, std::move(task), delay); } diff --git a/atom/app/uv_task_runner.h b/atom/app/uv_task_runner.h index 660c1dcef6c..34d839d09b6 100644 --- a/atom/app/uv_task_runner.h +++ b/atom/app/uv_task_runner.h @@ -25,10 +25,9 @@ class UvTaskRunner : public base::SingleThreadTaskRunner { base::OnceClosure task, base::TimeDelta delay) override; bool RunsTasksInCurrentSequence() const override; - bool PostNonNestableDelayedTask( - const base::Location& from_here, - base::OnceClosure task, - base::TimeDelta delay) override; + bool PostNonNestableDelayedTask(const base::Location& from_here, + base::OnceClosure task, + base::TimeDelta delay) override; private: static void OnTimeout(uv_timer_t* timer); diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index e5a6307a648..07e82b3e0fb 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -64,9 +64,10 @@ using atom::Browser; namespace mate { #if defined(OS_WIN) -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, Browser::UserTask* out) { mate::Dictionary dict; if (!ConvertFromV8(isolate, val, &dict)) @@ -83,13 +84,14 @@ struct Converter { } }; -using atom::JumpListItem; using atom::JumpListCategory; +using atom::JumpListItem; using atom::JumpListResult; -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, JumpListItem::Type* out) { std::string item_type; if (!ConvertFromV8(isolate, val, &item_type)) @@ -127,9 +129,10 @@ struct Converter { } }; -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, JumpListItem* out) { mate::Dictionary dict; if (!ConvertFromV8(isolate, val, &dict)) @@ -189,9 +192,10 @@ struct Converter { } }; -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, JumpListCategory::Type* out) { std::string category_type; if (!ConvertFromV8(isolate, val, &category_type)) @@ -235,9 +239,10 @@ struct Converter { } }; -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, JumpListCategory* out) { mate::Dictionary dict; if (!ConvertFromV8(isolate, val, &dict)) @@ -264,7 +269,7 @@ struct Converter { }; // static -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, JumpListResult val) { std::string result_code; @@ -298,9 +303,10 @@ struct Converter { }; #endif -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, Browser::LoginItemSettings* out) { mate::Dictionary dict; if (!ConvertFromV8(isolate, val, &dict)) @@ -325,15 +331,16 @@ struct Converter { } }; -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, content::CertificateRequestResultType* out) { bool b; if (!ConvertFromV8(isolate, val, &b)) return false; - *out = b ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE : - content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL; + *out = b ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE + : content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL; return true; } }; @@ -414,8 +421,8 @@ bool NotificationCallbackWrapper( } else { scoped_refptr task_runner( base::ThreadTaskRunnerHandle::Get()); - task_runner->PostTask( - FROM_HERE, base::Bind(base::IgnoreResult(callback), cmd, cwd)); + task_runner->PostTask(FROM_HERE, + base::Bind(base::IgnoreResult(callback), cmd, cwd)); } // ProcessSingleton needs to know whether current process is quiting. return !Browser::Get()->is_shutting_down(); @@ -479,9 +486,8 @@ void PassLoginInformation(scoped_refptr login_handler, } #if defined(USE_NSS_CERTS) -int ImportIntoCertStore( - CertificateManagerModel* model, - const base::DictionaryValue& options) { +int ImportIntoCertStore(CertificateManagerModel* model, + const base::DictionaryValue& options) { std::string file_data, cert_path; base::string16 password; net::ScopedCERTCertificateList imported_certs; @@ -492,17 +498,13 @@ int ImportIntoCertStore( if (!cert_path.empty()) { if (base::ReadFileToString(base::FilePath(cert_path), &file_data)) { auto module = model->cert_db()->GetPrivateSlot(); - rv = model->ImportFromPKCS12(module.get(), - file_data, - password, - true, + rv = model->ImportFromPKCS12(module.get(), file_data, password, true, &imported_certs); if (imported_certs.size() > 1) { auto it = imported_certs.begin(); ++it; // skip first which would be the client certificate. for (; it != imported_certs.end(); ++it) - rv &= model->SetCertTrust(it->get(), - net::CA_CERT, + rv &= model->SetCertTrust(it->get(), net::CA_CERT, net::NSSCertDatabase::TRUSTED_SSL); } } @@ -521,7 +523,7 @@ void OnIconDataAvailable(v8::Isolate* isolate, callback.Run(v8::Null(isolate), *icon); } else { v8::Local error_message = - v8::String::NewFromUtf8(isolate, "Failed to get file icon."); + v8::String::NewFromUtf8(isolate, "Failed to get file icon."); callback.Run(v8::Exception::Error(error_message), gfx::Image()); } } @@ -533,18 +535,16 @@ App::App(v8::Isolate* isolate) { Browser::Get()->AddObserver(this); content::GpuDataManager::GetInstance()->AddObserver(this); base::ProcessId pid = base::GetCurrentProcId(); - std::unique_ptr process_metric( - new atom::ProcessMetric( - content::PROCESS_TYPE_BROWSER, - pid, - base::ProcessMetrics::CreateCurrentProcessMetrics())); + std::unique_ptr process_metric(new atom::ProcessMetric( + content::PROCESS_TYPE_BROWSER, pid, + base::ProcessMetrics::CreateCurrentProcessMetrics())); app_metrics_[pid] = std::move(process_metric); Init(isolate); } App::~App() { - static_cast(AtomBrowserClient::Get())->set_delegate( - nullptr); + static_cast(AtomBrowserClient::Get()) + ->set_delegate(nullptr); Browser::Get()->RemoveObserver(this); content::GpuDataManager::GetInstance()->RemoveObserver(this); content::BrowserChildProcessObserver::Remove(this); @@ -609,35 +609,30 @@ void App::OnAccessibilitySupportChanged() { } #if defined(OS_MACOSX) -void App::OnWillContinueUserActivity( - bool* prevent_default, - const std::string& type) { +void App::OnWillContinueUserActivity(bool* prevent_default, + const std::string& type) { *prevent_default = Emit("will-continue-activity", type); } -void App::OnDidFailToContinueUserActivity( - const std::string& type, - const std::string& error) { +void App::OnDidFailToContinueUserActivity(const std::string& type, + const std::string& error) { Emit("continue-activity-error", type, error); } -void App::OnContinueUserActivity( - bool* prevent_default, - const std::string& type, - const base::DictionaryValue& user_info) { +void App::OnContinueUserActivity(bool* prevent_default, + const std::string& type, + const base::DictionaryValue& user_info) { *prevent_default = Emit("continue-activity", type, user_info); } -void App::OnUserActivityWasContinued( - const std::string& type, - const base::DictionaryValue& user_info) { +void App::OnUserActivityWasContinued(const std::string& type, + const base::DictionaryValue& user_info) { Emit("activity-was-continued", type, user_info); } -void App::OnUpdateUserActivityState( - bool* prevent_default, - const std::string& type, - const base::DictionaryValue& user_info) { +void App::OnUpdateUserActivityState(bool* prevent_default, + const std::string& type, + const base::DictionaryValue& user_info) { *prevent_default = Emit("update-activity-state", type, user_info); } @@ -654,12 +649,9 @@ void App::OnLogin(LoginHandler* login_handler, content::WebContents* web_contents = login_handler->GetWebContents(); if (web_contents) { prevent_default = - Emit("login", - WebContents::CreateFrom(isolate(), web_contents), - request_details, - login_handler->auth_info(), - base::Bind(&PassLoginInformation, - WrapRefCounted(login_handler))); + Emit("login", WebContents::CreateFrom(isolate(), web_contents), + request_details, login_handler->auth_info(), + base::Bind(&PassLoginInformation, WrapRefCounted(login_handler))); } // Default behavior is to always cancel the auth. @@ -708,12 +700,9 @@ void App::AllowCertificateError( callback) { v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); - bool prevent_default = Emit("certificate-error", - WebContents::CreateFrom(isolate(), web_contents), - request_url, - net::ErrorToString(cert_error), - ssl_info.cert, - callback); + bool prevent_default = Emit( + "certificate-error", WebContents::CreateFrom(isolate(), web_contents), + request_url, net::ErrorToString(cert_error), ssl_info.cert, callback); // Deny the certificate by default. if (!prevent_default) @@ -725,8 +714,8 @@ void App::SelectClientCertificate( net::SSLCertRequestInfo* cert_request_info, net::ClientCertIdentityList identities, std::unique_ptr delegate) { - std::shared_ptr - shared_delegate(delegate.release()); + std::shared_ptr shared_delegate( + delegate.release()); // Convert the ClientCertIdentityList to a CertificateList // to avoid changes in the API. @@ -756,7 +745,7 @@ void App::SelectClientCertificate( void App::OnGpuProcessCrashed(base::TerminationStatus status) { Emit("gpu-process-crashed", - status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED); + status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED); } void App::BrowserChildProcessLaunchedAndConnected( @@ -918,8 +907,9 @@ bool App::Relaunch(mate::Arguments* js_args) { void App::DisableHardwareAcceleration(mate::Arguments* args) { if (Browser::Get()->is_ready()) { - args->ThrowError("app.disableHardwareAcceleration() can only be called " - "before app is ready"); + args->ThrowError( + "app.disableHardwareAcceleration() can only be called " + "before app is ready"); return; } content::GpuDataManager::GetInstance()->DisableHardwareAcceleration(); @@ -958,18 +948,15 @@ Browser::LoginItemSettings App::GetLoginItemSettings(mate::Arguments* args) { } #if defined(USE_NSS_CERTS) -void App::ImportCertificate( - const base::DictionaryValue& options, - const net::CompletionCallback& callback) { +void App::ImportCertificate(const base::DictionaryValue& options, + const net::CompletionCallback& callback) { auto browser_context = AtomBrowserContext::From("", false); if (!certificate_manager_model_) { std::unique_ptr copy = options.CreateDeepCopy(); CertificateManagerModel::Create( browser_context.get(), base::Bind(&App::OnCertificateManagerModelCreated, - base::Unretained(this), - base::Passed(©), - callback)); + base::Unretained(this), base::Passed(©), callback)); return; } @@ -982,8 +969,8 @@ void App::OnCertificateManagerModelCreated( const net::CompletionCallback& callback, std::unique_ptr model) { certificate_manager_model_ = std::move(model); - int rv = ImportIntoCertStore(certificate_manager_model_.get(), - *(options.get())); + int rv = + ImportIntoCertStore(certificate_manager_model_.get(), *(options.get())); callback.Run(rv); } #endif @@ -1012,7 +999,7 @@ JumpListResult App::SetJumpList(v8::Local val, std::vector categories; bool delete_jump_list = val->IsNull(); if (!delete_jump_list && - !mate::ConvertFromV8(args->isolate(), val, &categories)) { + !mate::ConvertFromV8(args->isolate(), val, &categories)) { args->ThrowError("Argument must be null or an array of categories"); return JumpListResult::ARGUMENT_ERROR; } @@ -1020,9 +1007,8 @@ JumpListResult App::SetJumpList(v8::Local val, JumpList jump_list(Browser::Get()->GetAppUserModelID()); if (delete_jump_list) { - return jump_list.Delete() - ? JumpListResult::SUCCESS - : JumpListResult::GENERIC_ERROR; + return jump_list.Delete() ? JumpListResult::SUCCESS + : JumpListResult::GENERIC_ERROR; } // Start a transaction that updates the JumpList of this application. @@ -1045,8 +1031,7 @@ JumpListResult App::SetJumpList(v8::Local val, } #endif // defined(OS_WIN) -void App::GetFileIcon(const base::FilePath& path, - mate::Arguments* args) { +void App::GetFileIcon(const base::FilePath& path, mate::Arguments* args) { mate::Dictionary options; IconLoader::IconSize icon_size; FileIconCallback callback; @@ -1091,10 +1076,12 @@ std::vector App::GetAppMetrics(v8::Isolate* isolate) { mate::Dictionary memory_dict = mate::Dictionary::CreateEmpty(isolate); mate::Dictionary cpu_dict = mate::Dictionary::CreateEmpty(isolate); - memory_dict.Set("workingSetSize", + memory_dict.Set( + "workingSetSize", static_cast( process_metric.second->metrics->GetWorkingSetSize() >> 10)); - memory_dict.Set("peakWorkingSetSize", + memory_dict.Set( + "peakWorkingSetSize", static_cast( process_metric.second->metrics->GetPeakWorkingSetSize() >> 10)); @@ -1106,13 +1093,14 @@ std::vector App::GetAppMetrics(v8::Isolate* isolate) { } pid_dict.Set("memory", memory_dict); - cpu_dict.Set("percentCPUUsage", - process_metric.second->metrics->GetPlatformIndependentCPUUsage() - / processor_count); + cpu_dict.Set( + "percentCPUUsage", + process_metric.second->metrics->GetPlatformIndependentCPUUsage() / + processor_count); #if !defined(OS_WIN) cpu_dict.Set("idleWakeupsPerSecond", - process_metric.second->metrics->GetIdleWakeupsPerSecond()); + process_metric.second->metrics->GetIdleWakeupsPerSecond()); #else // Chrome's underlying process_metrics.cc will throw a non-fatal warning // that this method isn't implemented on Windows, so set it to 0 instead @@ -1122,8 +1110,8 @@ std::vector App::GetAppMetrics(v8::Isolate* isolate) { pid_dict.Set("cpu", cpu_dict); pid_dict.Set("pid", process_metric.second->pid); - pid_dict.Set("type", - content::GetProcessTypeNameInEnglish(process_metric.second->type)); + pid_dict.Set("type", content::GetProcessTypeNameInEnglish( + process_metric.second->type)); result.push_back(pid_dict); } @@ -1138,8 +1126,9 @@ v8::Local App::GetGPUFeatureStatus(v8::Isolate* isolate) { void App::EnableMixedSandbox(mate::Arguments* args) { if (Browser::Get()->is_ready()) { - args->ThrowError("app.enableMixedSandbox() can only be called " - "before app is ready"); + args->ThrowError( + "app.enableMixedSandbox() can only be called " + "before app is ready"); return; } @@ -1179,8 +1168,8 @@ mate::Handle App::Create(v8::Isolate* isolate) { } // static -void App::BuildPrototype( - v8::Isolate* isolate, v8::Local prototype) { +void App::BuildPrototype(v8::Isolate* isolate, + v8::Local prototype) { prototype->SetClassName(mate::StringToV8(isolate, "App")); auto browser = base::Unretained(Browser::Get()); mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) @@ -1255,15 +1244,15 @@ void App::BuildPrototype( .SetMethod("getFileIcon", &App::GetFileIcon) .SetMethod("getAppMetrics", &App::GetAppMetrics) .SetMethod("getGPUFeatureStatus", &App::GetGPUFeatureStatus) - // TODO(juturu): Remove in 2.0, deprecate before then with warnings - #if defined(OS_MACOSX) +// TODO(juturu): Remove in 2.0, deprecate before then with warnings +#if defined(OS_MACOSX) .SetMethod("moveToApplicationsFolder", &App::MoveToApplicationsFolder) .SetMethod("isInApplicationsFolder", &App::IsInApplicationsFolder) - #endif - #if defined(MAS_BUILD) +#endif +#if defined(MAS_BUILD) .SetMethod("startAccessingSecurityScopedResource", &App::StartAccessingSecurityScopedResource) - #endif +#endif .SetMethod("enableMixedSandbox", &App::EnableMixedSandbox); } @@ -1271,7 +1260,6 @@ void App::BuildPrototype( } // namespace atom - namespace { void AppendSwitch(const std::string& switch_string, mate::Arguments* args) { @@ -1308,8 +1296,10 @@ void DockSetMenu(atom::api::Menu* menu) { } #endif -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { v8::Isolate* isolate = context->GetIsolate(); auto command_line = base::CommandLine::ForCurrentProcess(); @@ -1317,9 +1307,8 @@ void Initialize(v8::Local exports, v8::Local unused, dict.Set("App", atom::api::App::GetConstructor(isolate)->GetFunction()); dict.Set("app", atom::api::App::Create(isolate)); dict.SetMethod("appendSwitch", &AppendSwitch); - dict.SetMethod("appendArgument", - base::Bind(&base::CommandLine::AppendArg, - base::Unretained(command_line))); + dict.SetMethod("appendArgument", base::Bind(&base::CommandLine::AppendArg, + base::Unretained(command_line))); #if defined(OS_MACOSX) auto browser = base::Unretained(Browser::Get()); dict.SetMethod("dockBounce", &DockBounce); diff --git a/atom/browser/api/atom_api_app.h b/atom/browser/api/atom_api_app.h index 59d1e31c14a..6c62152401c 100644 --- a/atom/browser/api/atom_api_app.h +++ b/atom/browser/api/atom_api_app.h @@ -67,8 +67,8 @@ class App : public AtomBrowserClient::Delegate, public content::GpuDataManagerObserver, public content::BrowserChildProcessObserver { public: - using FileIconCallback = base::Callback, - const gfx::Image&)>; + using FileIconCallback = + base::Callback, const gfx::Image&)>; static mate::Handle Create(v8::Isolate* isolate); @@ -106,16 +106,13 @@ class App : public AtomBrowserClient::Delegate, void OnAccessibilitySupportChanged() override; void OnPreMainMessageLoopRun() override; #if defined(OS_MACOSX) - void OnWillContinueUserActivity( - bool* prevent_default, - const std::string& type) override; - void OnDidFailToContinueUserActivity( - const std::string& type, - const std::string& error) override; - void OnContinueUserActivity( - bool* prevent_default, - const std::string& type, - const base::DictionaryValue& user_info) override; + void OnWillContinueUserActivity(bool* prevent_default, + const std::string& type) override; + void OnDidFailToContinueUserActivity(const std::string& type, + const std::string& error) override; + void OnContinueUserActivity(bool* prevent_default, + const std::string& type, + const base::DictionaryValue& user_info) override; void OnUserActivityWasContinued( const std::string& type, const base::DictionaryValue& user_info) override; @@ -166,10 +163,10 @@ class App : public AtomBrowserClient::Delegate, const content::ChildProcessData& data) override; void BrowserChildProcessHostDisconnected( const content::ChildProcessData& data) override; - void BrowserChildProcessCrashed( - const content::ChildProcessData& data, int exit_code) override; - void BrowserChildProcessKilled( - const content::ChildProcessData& data, int exit_code) override; + void BrowserChildProcessCrashed(const content::ChildProcessData& data, + int exit_code) override; + void BrowserChildProcessKilled(const content::ChildProcessData& data, + int exit_code) override; private: void SetAppPath(const base::FilePath& app_path); @@ -197,8 +194,7 @@ class App : public AtomBrowserClient::Delegate, void ImportCertificate(const base::DictionaryValue& options, const net::CompletionCallback& callback); #endif - void GetFileIcon(const base::FilePath& path, - mate::Arguments* args); + void GetFileIcon(const base::FilePath& path, mate::Arguments* args); std::vector GetAppMetrics(v8::Isolate* isolate); v8::Local GetGPUFeatureStatus(v8::Isolate* isolate); @@ -210,7 +206,7 @@ class App : public AtomBrowserClient::Delegate, #endif #if defined(MAS_BUILD) base::Callback StartAccessingSecurityScopedResource( - mate::Arguments* args); + mate::Arguments* args); #endif #if defined(OS_WIN) @@ -233,8 +229,7 @@ class App : public AtomBrowserClient::Delegate, base::FilePath app_path_; using ProcessMetricMap = - std::unordered_map>; + std::unordered_map>; ProcessMetricMap app_metrics_; DISALLOW_COPY_AND_ASSIGN(App); diff --git a/atom/browser/api/atom_api_auto_updater.cc b/atom/browser/api/atom_api_auto_updater.cc index 5d736ad43d7..3bee34247e9 100644 --- a/atom/browser/api/atom_api_auto_updater.cc +++ b/atom/browser/api/atom_api_auto_updater.cc @@ -16,12 +16,12 @@ namespace mate { -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, const base::Time& val) { - v8::MaybeLocal date = v8::Date::New( - isolate->GetCurrentContext(), val.ToJsTime()); + v8::MaybeLocal date = + v8::Date::New(isolate->GetCurrentContext(), val.ToJsTime()); if (date.IsEmpty()) return v8::Null(isolate); else @@ -49,21 +49,20 @@ void AutoUpdater::OnError(const std::string& message) { v8::HandleScope handle_scope(isolate()); auto error = v8::Exception::Error(mate::StringToV8(isolate(), message)); mate::EmitEvent( - isolate(), - GetWrapper(), - "error", + isolate(), GetWrapper(), "error", error->ToObject(isolate()->GetCurrentContext()).ToLocalChecked(), // Message is also emitted to keep compatibility with old code. message); } void AutoUpdater::OnError(const std::string& message, - const int code, const std::string& domain) { + const int code, + const std::string& domain) { v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); auto error = v8::Exception::Error(mate::StringToV8(isolate(), message)); - auto errorObject = error->ToObject( - isolate()->GetCurrentContext()).ToLocalChecked(); + auto errorObject = + error->ToObject(isolate()->GetCurrentContext()).ToLocalChecked(); // add two new params for better error handling errorObject->Set(mate::StringToV8(isolate(), "code"), @@ -123,8 +122,8 @@ mate::Handle AutoUpdater::Create(v8::Isolate* isolate) { } // static -void AutoUpdater::BuildPrototype( - v8::Isolate* isolate, v8::Local prototype) { +void AutoUpdater::BuildPrototype(v8::Isolate* isolate, + v8::Local prototype) { prototype->SetClassName(mate::StringToV8(isolate, "AutoUpdater")); mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) .SetMethod("checkForUpdates", &auto_updater::AutoUpdater::CheckForUpdates) @@ -137,13 +136,14 @@ void AutoUpdater::BuildPrototype( } // namespace atom - namespace { using atom::api::AutoUpdater; -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary dict(isolate, exports); dict.Set("autoUpdater", AutoUpdater::Create(isolate)); diff --git a/atom/browser/api/atom_api_auto_updater.h b/atom/browser/api/atom_api_auto_updater.h index 305313df52e..57d217cdfdf 100644 --- a/atom/browser/api/atom_api_auto_updater.h +++ b/atom/browser/api/atom_api_auto_updater.h @@ -32,7 +32,8 @@ class AutoUpdater : public mate::EventEmitter, // Delegate implementations. void OnError(const std::string& error) override; - void OnError(const std::string& message, const int code, + void OnError(const std::string& message, + const int code, const std::string& domain); void OnCheckingForUpdate() override; void OnUpdateAvailable() override; diff --git a/atom/browser/api/atom_api_browser_view.cc b/atom/browser/api/atom_api_browser_view.cc index 82e13a385f4..9c90426b969 100644 --- a/atom/browser/api/atom_api_browser_view.cc +++ b/atom/browser/api/atom_api_browser_view.cc @@ -153,9 +153,9 @@ void Initialize(v8::Local exports, mate::Dictionary browser_view( isolate, BrowserView::GetConstructor(isolate)->GetFunction()); browser_view.SetMethod("fromId", - &mate::TrackableObject::FromWeakMapID); + &mate::TrackableObject::FromWeakMapID); browser_view.SetMethod("getAllViews", - &mate::TrackableObject::GetAll); + &mate::TrackableObject::GetAll); mate::Dictionary dict(isolate, exports); dict.Set("BrowserView", browser_view); } diff --git a/atom/browser/api/atom_api_browser_window.cc b/atom/browser/api/atom_api_browser_window.cc index 83234f0ca34..b137ec092ed 100644 --- a/atom/browser/api/atom_api_browser_window.cc +++ b/atom/browser/api/atom_api_browser_window.cc @@ -29,8 +29,7 @@ namespace api { BrowserWindow::BrowserWindow(v8::Isolate* isolate, v8::Local wrapper, const mate::Dictionary& options) - : TopLevelWindow(isolate, wrapper, options), - weak_factory_(this) { + : TopLevelWindow(isolate, wrapper, options), weak_factory_(this) { mate::Handle web_contents; // Use options.webPreferences in WebContents. @@ -69,8 +68,8 @@ BrowserWindow::BrowserWindow(v8::Isolate* isolate, Observe(api_web_contents_->web_contents()); // Keep a copy of the options for later use. - mate::Dictionary(isolate, web_contents->GetWrapper()).Set( - "browserWindowOptions", options); + mate::Dictionary(isolate, web_contents->GetWrapper()) + .Set("browserWindowOptions", options); // Tell the content module to initialize renderer widget with transparent // mode. @@ -142,11 +141,12 @@ void BrowserWindow::DidFirstVisuallyNonEmptyPaint() { // Emit the ReadyToShow event in next tick in case of pending drawing work. base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, - base::Bind([](base::WeakPtr self) { - if (self) - self->Emit("ready-to-show"); - }, GetWeakPtr())); + FROM_HERE, base::Bind( + [](base::WeakPtr self) { + if (self) + self->Emit("ready-to-show"); + }, + GetWeakPtr())); } void BrowserWindow::BeforeUnloadDialogCancelled() { @@ -339,9 +339,7 @@ std::unique_ptr BrowserWindow::DraggableRegionsToSkRegion( std::unique_ptr sk_region(new SkRegion); for (const DraggableRegion& region : regions) { sk_region->op( - region.bounds.x(), - region.bounds.y(), - region.bounds.right(), + region.bounds.x(), region.bounds.y(), region.bounds.right(), region.bounds.bottom(), region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); } @@ -355,8 +353,7 @@ void BrowserWindow::ScheduleUnresponsiveEvent(int ms) { window_unresponsive_closure_.Reset( base::Bind(&BrowserWindow::NotifyWindowUnresponsive, GetWeakPtr())); base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, - window_unresponsive_closure_.callback(), + FROM_HERE, window_unresponsive_closure_.callback(), base::TimeDelta::FromMilliseconds(ms)); } @@ -397,7 +394,6 @@ mate::WrappableBase* BrowserWindow::New(mate::Arguments* args) { return new BrowserWindow(args->isolate(), args->GetThis(), options); } - // static void BrowserWindow::BuildPrototype(v8::Isolate* isolate, v8::Local prototype) { @@ -429,8 +425,10 @@ namespace { using atom::api::BrowserWindow; using atom::api::TopLevelWindow; -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { v8::Isolate* isolate = context->GetIsolate(); // Calling SetConstructor would only use TopLevelWindow's prototype. v8::Local templ = CreateFunctionTemplate( @@ -443,11 +441,9 @@ void Initialize(v8::Local exports, v8::Local unused, mate::Dictionary browser_window(isolate, templ->GetFunction()); browser_window.SetMethod( - "fromId", - &mate::TrackableObject::FromWeakMapID); - browser_window.SetMethod( - "getAllWindows", - &mate::TrackableObject::GetAll); + "fromId", &mate::TrackableObject::FromWeakMapID); + browser_window.SetMethod("getAllWindows", + &mate::TrackableObject::GetAll); mate::Dictionary dict(isolate, exports); dict.Set("BrowserWindow", browser_window); diff --git a/atom/browser/api/atom_api_browser_window.h b/atom/browser/api/atom_api_browser_window.h index 4433bf9f18b..7b1307922cd 100644 --- a/atom/browser/api/atom_api_browser_window.h +++ b/atom/browser/api/atom_api_browser_window.h @@ -82,9 +82,8 @@ class BrowserWindow : public TopLevelWindow, // Helpers. // Called when the window needs to update its draggable region. - void UpdateDraggableRegions( - content::RenderFrameHost* rfh, - const std::vector& regions); + void UpdateDraggableRegions(content::RenderFrameHost* rfh, + const std::vector& regions); // Convert draggable regions in raw format to SkRegion format. std::unique_ptr DraggableRegionsToSkRegion( @@ -121,9 +120,10 @@ class BrowserWindow : public TopLevelWindow, namespace mate { -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, atom::NativeWindow** out) { // null would be tranfered to NULL. if (val->IsNull()) { diff --git a/atom/browser/api/atom_api_browser_window_views.cc b/atom/browser/api/atom_api_browser_window_views.cc index 75043a83e30..d681f5a9232 100644 --- a/atom/browser/api/atom_api_browser_window_views.cc +++ b/atom/browser/api/atom_api_browser_window_views.cc @@ -15,8 +15,8 @@ void BrowserWindow::UpdateDraggableRegions( const std::vector& regions) { if (window_->has_frame()) return; - static_cast(window_.get())->UpdateDraggableRegions( - DraggableRegionsToSkRegion(regions)); + static_cast(window_.get()) + ->UpdateDraggableRegions(DraggableRegionsToSkRegion(regions)); } } // namespace api diff --git a/atom/browser/api/atom_api_content_tracing.cc b/atom/browser/api/atom_api_content_tracing.cc index 299d7173756..d340b167a5f 100644 --- a/atom/browser/api/atom_api_content_tracing.cc +++ b/atom/browser/api/atom_api_content_tracing.cc @@ -18,7 +18,7 @@ using content::TracingController; namespace mate { -template<> +template <> struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Local val, @@ -42,14 +42,14 @@ namespace { using CompletionCallback = base::Callback; scoped_refptr GetTraceDataEndpoint( - const base::FilePath& path, const CompletionCallback& callback) { + const base::FilePath& path, + const CompletionCallback& callback) { base::FilePath result_file_path = path; if (result_file_path.empty() && !base::CreateTemporaryFile(&result_file_path)) LOG(ERROR) << "Creating temporary file failed"; - return TracingController::CreateFileEndpoint(result_file_path, - base::Bind(callback, - result_file_path)); + return TracingController::CreateFileEndpoint( + result_file_path, base::Bind(callback, result_file_path)); } void StopRecording(const base::FilePath& path, @@ -58,17 +58,20 @@ void StopRecording(const base::FilePath& path, GetTraceDataEndpoint(path, callback)); } -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { auto controller = base::Unretained(TracingController::GetInstance()); mate::Dictionary dict(context->GetIsolate(), exports); - dict.SetMethod("getCategories", base::Bind( - &TracingController::GetCategories, controller)); - dict.SetMethod("startRecording", base::Bind( - &TracingController::StartTracing, controller)); + dict.SetMethod("getCategories", + base::Bind(&TracingController::GetCategories, controller)); + dict.SetMethod("startRecording", + base::Bind(&TracingController::StartTracing, controller)); dict.SetMethod("stopRecording", &StopRecording); - dict.SetMethod("getTraceBufferUsage", base::Bind( - &TracingController::GetTraceBufferUsage, controller)); + dict.SetMethod( + "getTraceBufferUsage", + base::Bind(&TracingController::GetTraceBufferUsage, controller)); } } // namespace diff --git a/atom/browser/api/atom_api_cookies.cc b/atom/browser/api/atom_api_cookies.cc index 3b33ec00a7c..7f9811db787 100644 --- a/atom/browser/api/atom_api_cookies.cc +++ b/atom/browser/api/atom_api_cookies.cc @@ -24,7 +24,7 @@ using content::BrowserThread; namespace mate { -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, atom::api::Cookies::Error val) { @@ -35,7 +35,7 @@ struct Converter { } }; -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, const net::CanonicalCookie& val) { @@ -54,7 +54,7 @@ struct Converter { } }; -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, const net::CookieStore::ChangeCause& val) { @@ -165,12 +165,13 @@ void GetCookiesOnIO(scoped_refptr getter, GetCookieStore(getter)->GetAllCookiesAsync(filtered_callback); else GetCookieStore(getter)->GetAllCookiesForURLAsync(GURL(url), - filtered_callback); + filtered_callback); } // Removes cookie with |url| and |name| in IO thread. void RemoveCookieOnIOThread(scoped_refptr getter, - const GURL& url, const std::string& name, + const GURL& url, + const std::string& name, const base::Closure& callback) { GetCookieStore(getter)->DeleteCookieAsync( url, name, base::Bind(RunCallbackInUI, callback)); @@ -209,30 +210,29 @@ void SetCookieOnIO(scoped_refptr getter, base::Time creation_time; if (details->GetDouble("creationDate", &creation_date)) { - creation_time = (creation_date == 0) ? - base::Time::UnixEpoch() : - base::Time::FromDoubleT(creation_date); + creation_time = (creation_date == 0) + ? base::Time::UnixEpoch() + : base::Time::FromDoubleT(creation_date); } base::Time expiration_time; if (details->GetDouble("expirationDate", &expiration_date)) { - expiration_time = (expiration_date == 0) ? - base::Time::UnixEpoch() : - base::Time::FromDoubleT(expiration_date); + expiration_time = (expiration_date == 0) + ? base::Time::UnixEpoch() + : base::Time::FromDoubleT(expiration_date); } base::Time last_access_time; if (details->GetDouble("lastAccessDate", &last_access_date)) { - last_access_time = (last_access_date == 0) ? - base::Time::UnixEpoch() : - base::Time::FromDoubleT(last_access_date); + last_access_time = (last_access_date == 0) + ? base::Time::UnixEpoch() + : base::Time::FromDoubleT(last_access_date); } GetCookieStore(getter)->SetCookieWithDetailsAsync( - GURL(url), name, value, domain, path, creation_time, - expiration_time, last_access_time, secure, http_only, - net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT, - base::Bind(OnSetCookie, callback)); + GURL(url), name, value, domain, path, creation_time, expiration_time, + last_access_time, secure, http_only, net::CookieSameSite::DEFAULT_MODE, + net::COOKIE_PRIORITY_DEFAULT, base::Bind(OnSetCookie, callback)); } } // namespace @@ -257,7 +257,8 @@ void Cookies::Get(const base::DictionaryValue& filter, callback)); } -void Cookies::Remove(const GURL& url, const std::string& name, +void Cookies::Remove(const GURL& url, + const std::string& name, const base::Closure& callback) { auto getter = browser_context_->GetRequestContext(); content::BrowserThread::PostTask( @@ -288,11 +289,9 @@ void Cookies::OnCookieChanged(const CookieDetails* details) { Emit("changed", *(details->cookie), details->cause, details->removed); } - // static -mate::Handle Cookies::Create( - v8::Isolate* isolate, - AtomBrowserContext* browser_context) { +mate::Handle Cookies::Create(v8::Isolate* isolate, + AtomBrowserContext* browser_context) { return mate::CreateHandle(isolate, new Cookies(isolate, browser_context)); } diff --git a/atom/browser/api/atom_api_cookies.h b/atom/browser/api/atom_api_cookies.h index d8a32d8fd4e..403e2262330 100644 --- a/atom/browser/api/atom_api_cookies.h +++ b/atom/browser/api/atom_api_cookies.h @@ -49,7 +49,8 @@ class Cookies : public mate::TrackableObject { ~Cookies() override; void Get(const base::DictionaryValue& filter, const GetCallback& callback); - void Remove(const GURL& url, const std::string& name, + void Remove(const GURL& url, + const std::string& name, const base::Closure& callback); void Set(const base::DictionaryValue& details, const SetCallback& callback); void FlushStore(const base::Closure& callback); diff --git a/atom/browser/api/atom_api_debugger.cc b/atom/browser/api/atom_api_debugger.cc index 58c028e3d41..6307b37f9ef 100644 --- a/atom/browser/api/atom_api_debugger.cc +++ b/atom/browser/api/atom_api_debugger.cc @@ -26,13 +26,11 @@ namespace atom { namespace api { Debugger::Debugger(v8::Isolate* isolate, content::WebContents* web_contents) - : web_contents_(web_contents), - previous_request_id_(0) { + : web_contents_(web_contents), previous_request_id_(0) { Init(isolate); } -Debugger::~Debugger() { -} +Debugger::~Debugger() {} void Debugger::AgentHostClosed(DevToolsAgentHost* agent_host, bool replaced_with_another_client) { @@ -144,9 +142,8 @@ void Debugger::SendCommand(mate::Arguments* args) { } // static -mate::Handle Debugger::Create( - v8::Isolate* isolate, - content::WebContents* web_contents) { +mate::Handle Debugger::Create(v8::Isolate* isolate, + content::WebContents* web_contents) { return mate::CreateHandle(isolate, new Debugger(isolate, web_contents)); } @@ -169,8 +166,10 @@ namespace { using atom::api::Debugger; -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary(isolate, exports) .Set("Debugger", Debugger::GetConstructor(isolate)->GetFunction()); diff --git a/atom/browser/api/atom_api_debugger.h b/atom/browser/api/atom_api_debugger.h index 2f7106efd7e..7441fac7974 100644 --- a/atom/browser/api/atom_api_debugger.h +++ b/atom/browser/api/atom_api_debugger.h @@ -17,7 +17,7 @@ namespace content { class DevToolsAgentHost; class WebContents; -} +} // namespace content namespace mate { class Arguments; @@ -27,15 +27,15 @@ namespace atom { namespace api { -class Debugger: public mate::TrackableObject, - public content::DevToolsAgentHostClient { +class Debugger : public mate::TrackableObject, + public content::DevToolsAgentHostClient { public: using SendCommandCallback = base::Callback; - static mate::Handle Create( - v8::Isolate* isolate, content::WebContents* web_contents); + static mate::Handle Create(v8::Isolate* isolate, + content::WebContents* web_contents); // mate::TrackableObject: static void BuildPrototype(v8::Isolate* isolate, diff --git a/atom/browser/api/atom_api_desktop_capturer.cc b/atom/browser/api/atom_api_desktop_capturer.cc index 9c3042a0eca..3bf2df9679a 100644 --- a/atom/browser/api/atom_api_desktop_capturer.cc +++ b/atom/browser/api/atom_api_desktop_capturer.cc @@ -53,14 +53,13 @@ DesktopCapturer::DesktopCapturer(v8::Isolate* isolate) { Init(isolate); } -DesktopCapturer::~DesktopCapturer() { -} +DesktopCapturer::~DesktopCapturer() {} void DesktopCapturer::StartHandling(bool capture_window, bool capture_screen, const gfx::Size& thumbnail_size) { webrtc::DesktopCaptureOptions options = - content::CreateDesktopCaptureOptions(); + content::CreateDesktopCaptureOptions(); #if defined(OS_WIN) using_directx_capturer_ = options.allow_directx_capturer(); #endif // defined(OS_WIN) @@ -71,27 +70,22 @@ void DesktopCapturer::StartHandling(bool capture_window, std::unique_ptr window_capturer( capture_window ? webrtc::DesktopCapturer::CreateWindowCapturer(options) : nullptr); - media_list_.reset(new NativeDesktopMediaList( - std::move(screen_capturer), std::move(window_capturer))); + media_list_.reset(new NativeDesktopMediaList(std::move(screen_capturer), + std::move(window_capturer))); media_list_->SetThumbnailSize(thumbnail_size); media_list_->StartUpdating(this); } -void DesktopCapturer::OnSourceAdded(int index) { -} +void DesktopCapturer::OnSourceAdded(int index) {} -void DesktopCapturer::OnSourceRemoved(int index) { -} +void DesktopCapturer::OnSourceRemoved(int index) {} -void DesktopCapturer::OnSourceMoved(int old_index, int new_index) { -} +void DesktopCapturer::OnSourceMoved(int old_index, int new_index) {} -void DesktopCapturer::OnSourceNameChanged(int index) { -} +void DesktopCapturer::OnSourceNameChanged(int index) {} -void DesktopCapturer::OnSourceThumbnailChanged(int index) { -} +void DesktopCapturer::OnSourceThumbnailChanged(int index) {} bool DesktopCapturer::OnRefreshFinished() { const auto media_list_sources = media_list_->GetSources(); @@ -131,14 +125,13 @@ bool DesktopCapturer::OnRefreshFinished() { for (auto& source : sources) { if (source.media_list_source.id.type == content::DesktopMediaID::TYPE_SCREEN) { - source.display_id = - base::Int64ToString(source.media_list_source.id.id); + source.display_id = base::Int64ToString(source.media_list_source.id.id); } } #endif // defined(OS_WIN) -// TODO(ajmacd): Add Linux support. The IDs across APIs differ but Chrome only -// supports capturing the entire desktop on Linux. Revisit this if individual -// screen support is added. + // TODO(ajmacd): Add Linux support. The IDs across APIs differ but Chrome only + // supports capturing the entire desktop on Linux. Revisit this if individual + // screen support is added. Emit("finished", sources); return false; @@ -151,7 +144,8 @@ mate::Handle DesktopCapturer::Create(v8::Isolate* isolate) { // static void DesktopCapturer::BuildPrototype( - v8::Isolate* isolate, v8::Local prototype) { + v8::Isolate* isolate, + v8::Local prototype) { prototype->SetClassName(mate::StringToV8(isolate, "DesktopCapturer")); mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) .SetMethod("startHandling", &DesktopCapturer::StartHandling); @@ -163,8 +157,10 @@ void DesktopCapturer::BuildPrototype( namespace { -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary dict(isolate, exports); dict.Set("desktopCapturer", atom::api::DesktopCapturer::Create(isolate)); diff --git a/atom/browser/api/atom_api_desktop_capturer.h b/atom/browser/api/atom_api_desktop_capturer.h index 77058896e0b..d933baac2ff 100644 --- a/atom/browser/api/atom_api_desktop_capturer.h +++ b/atom/browser/api/atom_api_desktop_capturer.h @@ -16,8 +16,8 @@ namespace atom { namespace api { -class DesktopCapturer: public mate::EventEmitter, - public DesktopMediaListObserver { +class DesktopCapturer : public mate::EventEmitter, + public DesktopMediaListObserver { public: struct Source { DesktopMediaList::Source media_list_source; diff --git a/atom/browser/api/atom_api_dialog.cc b/atom/browser/api/atom_api_dialog.cc index ff02c5fa009..bdbaffbb5bd 100644 --- a/atom/browser/api/atom_api_dialog.cc +++ b/atom/browser/api/atom_api_dialog.cc @@ -21,7 +21,7 @@ namespace mate { -template<> +template <> struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Local val, @@ -37,7 +37,7 @@ struct Converter { } }; -template<> +template <> struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Local val, @@ -54,9 +54,9 @@ struct Converter { dict.Get("filters", &(out->filters)); dict.Get("properties", &(out->properties)); dict.Get("showsTagField", &(out->shows_tag_field)); - #if defined(MAS_BUILD) +#if defined(MAS_BUILD) dict.Get("securityScopedBookmarks", &(out->security_scoped_bookmarks)); - #endif +#endif return true; } }; @@ -80,8 +80,7 @@ void ShowMessageBox(int type, mate::Arguments* args) { v8::Local peek = args->PeekNext(); atom::MessageBoxCallback callback; - if (mate::Converter::FromV8(args->isolate(), - peek, + if (mate::Converter::FromV8(args->isolate(), peek, &callback)) { atom::ShowMessageBox(window, static_cast(type), buttons, default_id, cancel_id, options, title, @@ -99,9 +98,8 @@ void ShowOpenDialog(const file_dialog::DialogSettings& settings, mate::Arguments* args) { v8::Local peek = args->PeekNext(); file_dialog::OpenDialogCallback callback; - if (mate::Converter::FromV8(args->isolate(), - peek, - &callback)) { + if (mate::Converter::FromV8( + args->isolate(), peek, &callback)) { file_dialog::ShowOpenDialog(settings, callback); } else { std::vector paths; @@ -114,9 +112,8 @@ void ShowSaveDialog(const file_dialog::DialogSettings& settings, mate::Arguments* args) { v8::Local peek = args->PeekNext(); file_dialog::SaveDialogCallback callback; - if (mate::Converter::FromV8(args->isolate(), - peek, - &callback)) { + if (mate::Converter::FromV8( + args->isolate(), peek, &callback)) { file_dialog::ShowSaveDialog(settings, callback); } else { base::FilePath path; @@ -125,8 +122,10 @@ void ShowSaveDialog(const file_dialog::DialogSettings& settings, } } -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { mate::Dictionary dict(context->GetIsolate(), exports); dict.SetMethod("showMessageBox", &ShowMessageBox); dict.SetMethod("showErrorBox", &atom::ShowErrorBox); diff --git a/atom/browser/api/atom_api_download_item.cc b/atom/browser/api/atom_api_download_item.cc index 491cc18538b..d2b86ce5d64 100644 --- a/atom/browser/api/atom_api_download_item.cc +++ b/atom/browser/api/atom_api_download_item.cc @@ -19,7 +19,7 @@ namespace mate { -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, content::DownloadItem::DownloadState state) { @@ -79,8 +79,8 @@ void DownloadItem::OnDownloadUpdated(content::DownloadItem* item) { if (download_item_->IsDone()) { Emit("done", item->GetState()); // Destroy the item once item is downloaded. - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, GetDestroyClosure()); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + GetDestroyClosure()); } else { Emit("updated", item->GetState()); } @@ -129,12 +129,11 @@ bool DownloadItem::HasUserGesture() const { } std::string DownloadItem::GetFilename() const { - return base::UTF16ToUTF8(net::GenerateFileName(GetURL(), - GetContentDisposition(), - std::string(), - download_item_->GetSuggestedFilename(), - GetMimeType(), - "download").LossyDisplayName()); + return base::UTF16ToUTF8( + net::GenerateFileName(GetURL(), GetContentDisposition(), std::string(), + download_item_->GetSuggestedFilename(), + GetMimeType(), "download") + .LossyDisplayName()); } std::string DownloadItem::GetContentDisposition() const { @@ -206,8 +205,8 @@ void DownloadItem::BuildPrototype(v8::Isolate* isolate, } // static -mate::Handle DownloadItem::Create( - v8::Isolate* isolate, content::DownloadItem* item) { +mate::Handle DownloadItem::Create(v8::Isolate* isolate, + content::DownloadItem* item) { auto existing = TrackableObject::FromWrappedClass(isolate, item); if (existing) return mate::CreateHandle(isolate, static_cast(existing)); @@ -226,8 +225,10 @@ mate::Handle DownloadItem::Create( namespace { -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary(isolate, exports) .Set("DownloadItem", diff --git a/atom/browser/api/atom_api_global_shortcut.cc b/atom/browser/api/atom_api_global_shortcut.cc index a33ba7e45e5..4fc7532d9e3 100644 --- a/atom/browser/api/atom_api_global_shortcut.cc +++ b/atom/browser/api/atom_api_global_shortcut.cc @@ -40,8 +40,8 @@ void GlobalShortcut::OnKeyPressed(const ui::Accelerator& accelerator) { bool GlobalShortcut::Register(const ui::Accelerator& accelerator, const base::Closure& callback) { - if (!GlobalShortcutListener::GetInstance()->RegisterAccelerator( - accelerator, this)) { + if (!GlobalShortcutListener::GetInstance()->RegisterAccelerator(accelerator, + this)) { return false; } @@ -54,8 +54,8 @@ void GlobalShortcut::Unregister(const ui::Accelerator& accelerator) { return; accelerator_callback_map_.erase(accelerator); - GlobalShortcutListener::GetInstance()->UnregisterAccelerator( - accelerator, this); + GlobalShortcutListener::GetInstance()->UnregisterAccelerator(accelerator, + this); } bool GlobalShortcut::IsRegistered(const ui::Accelerator& accelerator) { @@ -73,8 +73,8 @@ mate::Handle GlobalShortcut::Create(v8::Isolate* isolate) { } // static -void GlobalShortcut::BuildPrototype( - v8::Isolate* isolate, v8::Local prototype) { +void GlobalShortcut::BuildPrototype(v8::Isolate* isolate, + v8::Local prototype) { prototype->SetClassName(mate::StringToV8(isolate, "GlobalShortcut")); mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) .SetMethod("register", &GlobalShortcut::Register) @@ -89,8 +89,10 @@ void GlobalShortcut::BuildPrototype( namespace { -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary dict(isolate, exports); dict.Set("globalShortcut", atom::api::GlobalShortcut::Create(isolate)); diff --git a/atom/browser/api/atom_api_in_app_purchase.cc b/atom/browser/api/atom_api_in_app_purchase.cc index ecfb146bd28..af25f73181a 100644 --- a/atom/browser/api/atom_api_in_app_purchase.cc +++ b/atom/browser/api/atom_api_in_app_purchase.cc @@ -99,8 +99,7 @@ InAppPurchase::InAppPurchase(v8::Isolate* isolate) { Init(isolate); } -InAppPurchase::~InAppPurchase() { -} +InAppPurchase::~InAppPurchase() {} void InAppPurchase::PurchaseProduct(const std::string& product_id, mate::Arguments* args) { diff --git a/atom/browser/api/atom_api_menu.cc b/atom/browser/api/atom_api_menu.cc index 14a38c87019..b259c2f23a0 100644 --- a/atom/browser/api/atom_api_menu.cc +++ b/atom/browser/api/atom_api_menu.cc @@ -20,8 +20,7 @@ namespace atom { namespace api { Menu::Menu(v8::Isolate* isolate, v8::Local wrapper) - : model_(new AtomMenuModel(this)), - parent_(nullptr) { + : model_(new AtomMenuModel(this)), parent_(nullptr) { InitWith(isolate, wrapper); model_->AddObserver(this); } @@ -70,18 +69,17 @@ bool Menu::GetAcceleratorForCommandIdWithParams( ui::Accelerator* accelerator) const { v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); - v8::Local val = get_accelerator_.Run( - GetWrapper(), command_id, use_default_accelerator); + v8::Local val = + get_accelerator_.Run(GetWrapper(), command_id, use_default_accelerator); return mate::ConvertFromV8(isolate(), val, accelerator); } void Menu::ExecuteCommand(int command_id, int flags) { v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); - execute_command_.Run( - GetWrapper(), - mate::internal::CreateEventFromFlags(isolate(), flags), - command_id); + execute_command_.Run(GetWrapper(), + mate::internal::CreateEventFromFlags(isolate(), flags), + command_id); } void Menu::MenuWillShow(ui::SimpleMenuModel* source) { @@ -90,8 +88,9 @@ void Menu::MenuWillShow(ui::SimpleMenuModel* source) { menu_will_show_.Run(GetWrapper()); } -void Menu::InsertItemAt( - int index, int command_id, const base::string16& label) { +void Menu::InsertItemAt(int index, + int command_id, + const base::string16& label) { model_->InsertItemAt(index, command_id, label); } @@ -207,13 +206,14 @@ void Menu::BuildPrototype(v8::Isolate* isolate, } // namespace atom - namespace { using atom::api::Menu; -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { v8::Isolate* isolate = context->GetIsolate(); Menu::SetConstructor(isolate, base::Bind(&Menu::New)); diff --git a/atom/browser/api/atom_api_menu.h b/atom/browser/api/atom_api_menu.h index 94cd6d5cc8a..2770742ce28 100644 --- a/atom/browser/api/atom_api_menu.h +++ b/atom/browser/api/atom_api_menu.h @@ -18,8 +18,8 @@ namespace atom { namespace api { class Menu : public mate::TrackableObject, - public AtomMenuModel::Delegate, - public AtomMenuModel::Observer { + public AtomMenuModel::Delegate, + public AtomMenuModel::Observer { public: static mate::WrappableBase* New(mate::Arguments* args); @@ -55,7 +55,9 @@ class Menu : public mate::TrackableObject, void MenuWillShow(ui::SimpleMenuModel* source) override; virtual void PopupAt(BrowserWindow* window, - int x, int y, int positioning_item, + int x, + int y, + int positioning_item, const base::Closure& callback) = 0; virtual void ClosePopupAt(int32_t window_id) = 0; @@ -110,12 +112,12 @@ class Menu : public mate::TrackableObject, } // namespace atom - namespace mate { -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, atom::AtomMenuModel** out) { // null would be tranfered to NULL. if (val->IsNull()) { diff --git a/atom/browser/api/atom_api_menu_mac.h b/atom/browser/api/atom_api_menu_mac.h index 252801ca072..5b4816ea846 100644 --- a/atom/browser/api/atom_api_menu_mac.h +++ b/atom/browser/api/atom_api_menu_mac.h @@ -23,7 +23,9 @@ class MenuMac : public Menu { MenuMac(v8::Isolate* isolate, v8::Local wrapper); void PopupAt(BrowserWindow* window, - int x, int y, int positioning_item, + int x, + int y, + int positioning_item, const base::Closure& callback) override; void PopupOnUI(const base::WeakPtr& native_window, int32_t window_id, diff --git a/atom/browser/api/atom_api_menu_views.cc b/atom/browser/api/atom_api_menu_views.cc index bae1292dd1c..52d2fb726c9 100644 --- a/atom/browser/api/atom_api_menu_views.cc +++ b/atom/browser/api/atom_api_menu_views.cc @@ -17,12 +17,12 @@ namespace atom { namespace api { MenuViews::MenuViews(v8::Isolate* isolate, v8::Local wrapper) - : Menu(isolate, wrapper), - weak_factory_(this) { -} + : Menu(isolate, wrapper), weak_factory_(this) {} void MenuViews::PopupAt(BrowserWindow* window, - int x, int y, int positioning_item, + int x, + int y, + int positioning_item, const base::Closure& callback) { auto* native_window = static_cast(window->window()); if (!native_window) @@ -46,14 +46,11 @@ void MenuViews::PopupAt(BrowserWindow* window, int32_t window_id = window->weak_map_id(); auto close_callback = base::Bind( &MenuViews::OnClosed, weak_factory_.GetWeakPtr(), window_id, callback); - menu_runners_[window_id] = std::unique_ptr(new MenuRunner( - model(), flags, close_callback)); + menu_runners_[window_id] = std::unique_ptr( + new MenuRunner(model(), flags, close_callback)); menu_runners_[window_id]->RunMenuAt( - native_window->widget(), - NULL, - gfx::Rect(location, gfx::Size()), - views::MENU_ANCHOR_TOPLEFT, - ui::MENU_SOURCE_MOUSE); + native_window->widget(), NULL, gfx::Rect(location, gfx::Size()), + views::MENU_ANCHOR_TOPLEFT, ui::MENU_SOURCE_MOUSE); } void MenuViews::ClosePopupAt(int32_t window_id) { diff --git a/atom/browser/api/atom_api_menu_views.h b/atom/browser/api/atom_api_menu_views.h index ba82b6d336b..31d7d48db8e 100644 --- a/atom/browser/api/atom_api_menu_views.h +++ b/atom/browser/api/atom_api_menu_views.h @@ -22,7 +22,9 @@ class MenuViews : public Menu { protected: void PopupAt(BrowserWindow* window, - int x, int y, int positioning_item, + int x, + int y, + int positioning_item, const base::Closure& callback) override; void ClosePopupAt(int32_t window_id) override; diff --git a/atom/browser/api/atom_api_notification.cc b/atom/browser/api/atom_api_notification.cc index 3eb99be4325..66fe2d5ecbb 100644 --- a/atom/browser/api/atom_api_notification.cc +++ b/atom/browser/api/atom_api_notification.cc @@ -20,10 +20,11 @@ #include "atom/common/node_includes.h" namespace mate { -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, - brightray::NotificationAction* out) { + static bool FromV8(v8::Isolate* isolate, + v8::Local val, + brightray::NotificationAction* out) { mate::Dictionary dict; if (!ConvertFromV8(isolate, val, &dict)) return false; @@ -36,7 +37,7 @@ struct Converter { } static v8::Local ToV8(v8::Isolate* isolate, - brightray::NotificationAction val) { + brightray::NotificationAction val) { mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate); dict.Set("text", val.text); dict.Set("type", val.type); @@ -155,7 +156,7 @@ void Notification::SetSound(const base::string16& new_sound) { } void Notification::SetActions( - const std::vector& actions) { + const std::vector& actions) { actions_ = actions; } @@ -179,8 +180,7 @@ void Notification::NotificationDisplayed() { Emit("show"); } -void Notification::NotificationDestroyed() { -} +void Notification::NotificationDestroyed() {} void Notification::NotificationClosed() { Emit("close"); @@ -232,14 +232,12 @@ void Notification::BuildPrototype(v8::Isolate* isolate, .SetProperty("subtitle", &Notification::GetSubtitle, &Notification::SetSubtitle) .SetProperty("body", &Notification::GetBody, &Notification::SetBody) - .SetProperty("silent", &Notification::GetSilent, - &Notification::SetSilent) + .SetProperty("silent", &Notification::GetSilent, &Notification::SetSilent) .SetProperty("hasReply", &Notification::GetHasReply, &Notification::SetHasReply) .SetProperty("replyPlaceholder", &Notification::GetReplyPlaceholder, &Notification::SetReplyPlaceholder) - .SetProperty("sound", &Notification::GetSound, - &Notification::SetSound) + .SetProperty("sound", &Notification::GetSound, &Notification::SetSound) .SetProperty("actions", &Notification::GetActions, &Notification::SetActions) .SetProperty("closeButtonText", &Notification::GetCloseButtonText, diff --git a/atom/browser/api/atom_api_power_monitor.cc b/atom/browser/api/atom_api_power_monitor.cc index adac90c4300..5c28000b47f 100644 --- a/atom/browser/api/atom_api_power_monitor.cc +++ b/atom/browser/api/atom_api_power_monitor.cc @@ -13,7 +13,7 @@ #include "atom/common/node_includes.h" namespace mate { -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, const ui::IdleState& in) { @@ -38,11 +38,11 @@ namespace api { PowerMonitor::PowerMonitor(v8::Isolate* isolate) { #if defined(OS_LINUX) - SetShutdownHandler(base::Bind(&PowerMonitor::ShouldShutdown, - base::Unretained(this))); + SetShutdownHandler( + base::Bind(&PowerMonitor::ShouldShutdown, base::Unretained(this))); #elif defined(OS_MACOSX) - Browser::Get()->SetShutdownHandler(base::Bind(&PowerMonitor::ShouldShutdown, - base::Unretained(this))); + Browser::Get()->SetShutdownHandler( + base::Bind(&PowerMonitor::ShouldShutdown, base::Unretained(this))); #endif base::PowerMonitor::Get()->AddObserver(this); Init(isolate); @@ -87,9 +87,8 @@ void PowerMonitor::QuerySystemIdleState(v8::Isolate* isolate, if (idle_threshold > 0) { ui::CalculateIdleState(idle_threshold, callback); } else { - isolate->ThrowException(v8::Exception::TypeError( - mate::StringToV8(isolate, - "Invalid idle threshold, must be greater than 0"))); + isolate->ThrowException(v8::Exception::TypeError(mate::StringToV8( + isolate, "Invalid idle threshold, must be greater than 0"))); } } @@ -110,31 +109,32 @@ v8::Local PowerMonitor::Create(v8::Isolate* isolate) { } // static -void PowerMonitor::BuildPrototype( - v8::Isolate* isolate, v8::Local prototype) { +void PowerMonitor::BuildPrototype(v8::Isolate* isolate, + v8::Local prototype) { prototype->SetClassName(mate::StringToV8(isolate, "PowerMonitor")); mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) - .MakeDestroyable() + .MakeDestroyable() #if defined(OS_LINUX) - .SetMethod("blockShutdown", &PowerMonitor::BlockShutdown) - .SetMethod("unblockShutdown", &PowerMonitor::UnblockShutdown) + .SetMethod("blockShutdown", &PowerMonitor::BlockShutdown) + .SetMethod("unblockShutdown", &PowerMonitor::UnblockShutdown) #endif - .SetMethod("querySystemIdleState", &PowerMonitor::QuerySystemIdleState) - .SetMethod("querySystemIdleTime", &PowerMonitor::QuerySystemIdleTime); + .SetMethod("querySystemIdleState", &PowerMonitor::QuerySystemIdleState) + .SetMethod("querySystemIdleTime", &PowerMonitor::QuerySystemIdleTime); } } // namespace api } // namespace atom - namespace { using atom::api::PowerMonitor; -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary dict(isolate, exports); dict.Set("powerMonitor", PowerMonitor::Create(isolate)); diff --git a/atom/browser/api/atom_api_power_save_blocker.cc b/atom/browser/api/atom_api_power_save_blocker.cc index 37aef91af9c..51df0a63a5e 100644 --- a/atom/browser/api/atom_api_power_save_blocker.cc +++ b/atom/browser/api/atom_api_power_save_blocker.cc @@ -15,7 +15,7 @@ using content::BrowserThread; namespace mate { -template<> +template <> struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Local val, @@ -46,8 +46,7 @@ PowerSaveBlocker::PowerSaveBlocker(v8::Isolate* isolate) Init(isolate); } -PowerSaveBlocker::~PowerSaveBlocker() { -} +PowerSaveBlocker::~PowerSaveBlocker() {} void PowerSaveBlocker::UpdatePowerSaveBlocker() { if (power_save_blocker_types_.empty()) { @@ -75,8 +74,7 @@ void PowerSaveBlocker::UpdatePowerSaveBlocker() { if (!power_save_blocker_ || new_blocker_type != current_blocker_type_) { std::unique_ptr new_blocker( new device::PowerSaveBlocker( - new_blocker_type, - device::PowerSaveBlocker::kReasonOther, + new_blocker_type, device::PowerSaveBlocker::kReasonOther, ATOM_PRODUCT_NAME, BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE))); @@ -110,7 +108,8 @@ mate::Handle PowerSaveBlocker::Create(v8::Isolate* isolate) { // static void PowerSaveBlocker::BuildPrototype( - v8::Isolate* isolate, v8::Local prototype) { + v8::Isolate* isolate, + v8::Local prototype) { prototype->SetClassName(mate::StringToV8(isolate, "PowerSaveBlocker")); mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) .SetMethod("start", &PowerSaveBlocker::Start) @@ -124,8 +123,10 @@ void PowerSaveBlocker::BuildPrototype( namespace { -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary dict(isolate, exports); dict.Set("powerSaveBlocker", atom::api::PowerSaveBlocker::Create(isolate)); diff --git a/atom/browser/api/atom_api_protocol.cc b/atom/browser/api/atom_api_protocol.cc index 292bfef9bf9..e66a655a77b 100644 --- a/atom/browser/api/atom_api_protocol.cc +++ b/atom/browser/api/atom_api_protocol.cc @@ -63,7 +63,7 @@ void RegisterStandardSchemes(const std::vector& schemes, atom::switches::kStandardSchemes, base::JoinString(schemes, ",")); if (secure) { base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( - atom::switches::kSecureSchemes, base::JoinString(schemes, ",")); + atom::switches::kSecureSchemes, base::JoinString(schemes, ",")); } } @@ -72,16 +72,15 @@ Protocol::Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context) Init(isolate); } -Protocol::~Protocol() { -} +Protocol::~Protocol() {} void Protocol::RegisterServiceWorkerSchemes( const std::vector& schemes) { atom::AtomBrowserClient::SetCustomServiceWorkerSchemes(schemes); } -void Protocol::UnregisterProtocol( - const std::string& scheme, mate::Arguments* args) { +void Protocol::UnregisterProtocol(const std::string& scheme, + mate::Arguments* args) { CompletionCallback callback; args->GetNext(&callback); auto getter = browser_context_->GetRequestContext(); @@ -121,8 +120,8 @@ bool Protocol::IsProtocolHandledInIO( return request_context_getter->job_factory()->IsHandledProtocol(scheme); } -void Protocol::UninterceptProtocol( - const std::string& scheme, mate::Arguments* args) { +void Protocol::UninterceptProtocol(const std::string& scheme, + mate::Arguments* args) { CompletionCallback callback; args->GetNext(&callback); auto getter = browser_context_->GetRequestContext(); @@ -138,12 +137,14 @@ Protocol::ProtocolError Protocol::UninterceptProtocolInIO( scoped_refptr request_context_getter, const std::string& scheme) { return static_cast( - request_context_getter->job_factory())->UninterceptProtocol(scheme) ? - PROTOCOL_OK : PROTOCOL_NOT_INTERCEPTED; + request_context_getter->job_factory()) + ->UninterceptProtocol(scheme) + ? PROTOCOL_OK + : PROTOCOL_NOT_INTERCEPTED; } -void Protocol::OnIOCompleted( - const CompletionCallback& callback, ProtocolError error) { +void Protocol::OnIOCompleted(const CompletionCallback& callback, + ProtocolError error) { // The completion callback is optional. if (callback.is_null()) return; @@ -161,24 +162,30 @@ void Protocol::OnIOCompleted( std::string Protocol::ErrorCodeToString(ProtocolError error) { switch (error) { - case PROTOCOL_FAIL: return "Failed to manipulate protocol factory"; - case PROTOCOL_REGISTERED: return "The scheme has been registered"; - case PROTOCOL_NOT_REGISTERED: return "The scheme has not been registered"; - case PROTOCOL_INTERCEPTED: return "The scheme has been intercepted"; - case PROTOCOL_NOT_INTERCEPTED: return "The scheme has not been intercepted"; - default: return "Unexpected error"; + case PROTOCOL_FAIL: + return "Failed to manipulate protocol factory"; + case PROTOCOL_REGISTERED: + return "The scheme has been registered"; + case PROTOCOL_NOT_REGISTERED: + return "The scheme has not been registered"; + case PROTOCOL_INTERCEPTED: + return "The scheme has been intercepted"; + case PROTOCOL_NOT_INTERCEPTED: + return "The scheme has not been intercepted"; + default: + return "Unexpected error"; } } // static -mate::Handle Protocol::Create( - v8::Isolate* isolate, AtomBrowserContext* browser_context) { +mate::Handle Protocol::Create(v8::Isolate* isolate, + AtomBrowserContext* browser_context) { return mate::CreateHandle(isolate, new Protocol(isolate, browser_context)); } // static -void Protocol::BuildPrototype( - v8::Isolate* isolate, v8::Local prototype) { +void Protocol::BuildPrototype(v8::Isolate* isolate, + v8::Local prototype) { prototype->SetClassName(mate::StringToV8(isolate, "Protocol")); mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) .SetMethod("registerServiceWorkerSchemes", @@ -214,19 +221,22 @@ void Protocol::BuildPrototype( namespace { -void RegisterStandardSchemes( - const std::vector& schemes, mate::Arguments* args) { +void RegisterStandardSchemes(const std::vector& schemes, + mate::Arguments* args) { if (atom::Browser::Get()->is_ready()) { - args->ThrowError("protocol.registerStandardSchemes should be called before " - "app is ready"); + args->ThrowError( + "protocol.registerStandardSchemes should be called before " + "app is ready"); return; } atom::api::RegisterStandardSchemes(schemes, args); } -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary dict(isolate, exports); dict.SetMethod("registerStandardSchemes", &RegisterStandardSchemes); diff --git a/atom/browser/api/atom_api_protocol.h b/atom/browser/api/atom_api_protocol.h index 52e30966db9..698331566ff 100644 --- a/atom/browser/api/atom_api_protocol.h +++ b/atom/browser/api/atom_api_protocol.h @@ -39,8 +39,8 @@ class Protocol : public mate::TrackableObject { using CompletionCallback = base::Callback)>; using BooleanCallback = base::Callback; - static mate::Handle Create( - v8::Isolate* isolate, AtomBrowserContext* browser_context); + static mate::Handle Create(v8::Isolate* isolate, + AtomBrowserContext* browser_context); static void BuildPrototype(v8::Isolate* isolate, v8::Local prototype); @@ -52,7 +52,7 @@ class Protocol : public mate::TrackableObject { private: // Possible errors. enum ProtocolError { - PROTOCOL_OK, // no error + PROTOCOL_OK, // no error PROTOCOL_FAIL, // operation failed, should never occur PROTOCOL_REGISTERED, PROTOCOL_NOT_REGISTERED, @@ -62,14 +62,13 @@ class Protocol : public mate::TrackableObject { // The protocol handler that will create a protocol handler for certain // request job. - template + template class CustomProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler { public: - CustomProtocolHandler( - v8::Isolate* isolate, - net::URLRequestContextGetter* request_context, - const Handler& handler) + CustomProtocolHandler(v8::Isolate* isolate, + net::URLRequestContextGetter* request_context, + const Handler& handler) : isolate_(isolate), request_context_(request_context), handler_(handler) {} @@ -95,7 +94,7 @@ class Protocol : public mate::TrackableObject { void RegisterServiceWorkerSchemes(const std::vector& schemes); // Register the protocol with certain request job. - template + template void RegisterProtocol(const std::string& scheme, const Handler& handler, mate::Arguments* args) { @@ -108,7 +107,7 @@ class Protocol : public mate::TrackableObject { base::RetainedRef(getter), isolate(), scheme, handler), base::BindOnce(&Protocol::OnIOCompleted, GetWeakPtr(), callback)); } - template + template static ProtocolError RegisterProtocolInIO( scoped_refptr request_context_getter, v8::Isolate* isolate, @@ -141,7 +140,7 @@ class Protocol : public mate::TrackableObject { const std::string& scheme); // Replace the protocol handler with a new one. - template + template void InterceptProtocol(const std::string& scheme, const Handler& handler, mate::Arguments* args) { @@ -154,7 +153,7 @@ class Protocol : public mate::TrackableObject { base::RetainedRef(getter), isolate(), scheme, handler), base::BindOnce(&Protocol::OnIOCompleted, GetWeakPtr(), callback)); } - template + template static ProtocolError InterceptProtocolInIO( scoped_refptr request_context_getter, v8::Isolate* isolate, @@ -187,9 +186,7 @@ class Protocol : public mate::TrackableObject { // Convert error code to string. std::string ErrorCodeToString(ProtocolError error); - base::WeakPtr GetWeakPtr() { - return weak_factory_.GetWeakPtr(); - } + base::WeakPtr GetWeakPtr() { return weak_factory_.GetWeakPtr(); } scoped_refptr browser_context_; base::WeakPtrFactory weak_factory_; diff --git a/atom/browser/api/atom_api_render_process_preferences.cc b/atom/browser/api/atom_api_render_process_preferences.cc index d57a8e78a41..98c6cca2f0e 100644 --- a/atom/browser/api/atom_api_render_process_preferences.cc +++ b/atom/browser/api/atom_api_render_process_preferences.cc @@ -21,8 +21,8 @@ namespace { bool IsWebContents(v8::Isolate* isolate, content::RenderProcessHost* process) { content::WebContents* web_contents = - static_cast(AtomBrowserClient::Get())-> - GetWebContentsFromProcessID(process->GetID()); + static_cast(AtomBrowserClient::Get()) + ->GetWebContentsFromProcessID(process->GetID()); if (!web_contents) return false; @@ -41,8 +41,7 @@ RenderProcessPreferences::RenderProcessPreferences( Init(isolate); } -RenderProcessPreferences::~RenderProcessPreferences() { -} +RenderProcessPreferences::~RenderProcessPreferences() {} int RenderProcessPreferences::AddEntry(const base::DictionaryValue& entry) { return preferences_.AddEntry(entry); @@ -54,7 +53,8 @@ void RenderProcessPreferences::RemoveEntry(int id) { // static void RenderProcessPreferences::BuildPrototype( - v8::Isolate* isolate, v8::Local prototype) { + v8::Isolate* isolate, + v8::Local prototype) { prototype->SetClassName( mate::StringToV8(isolate, "RenderProcessPreferences")); mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) @@ -65,10 +65,9 @@ void RenderProcessPreferences::BuildPrototype( // static mate::Handle RenderProcessPreferences::ForAllWebContents(v8::Isolate* isolate) { - return mate::CreateHandle( - isolate, - new RenderProcessPreferences(isolate, - base::Bind(&IsWebContents, isolate))); + return mate::CreateHandle(isolate, + new RenderProcessPreferences( + isolate, base::Bind(&IsWebContents, isolate))); } } // namespace api @@ -77,8 +76,10 @@ RenderProcessPreferences::ForAllWebContents(v8::Isolate* isolate) { namespace { -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { mate::Dictionary dict(context->GetIsolate(), exports); dict.SetMethod("forAllWebContents", &atom::api::RenderProcessPreferences::ForAllWebContents); diff --git a/atom/browser/api/atom_api_render_process_preferences.h b/atom/browser/api/atom_api_render_process_preferences.h index 19cc0d8821f..c1791b7b110 100644 --- a/atom/browser/api/atom_api_render_process_preferences.h +++ b/atom/browser/api/atom_api_render_process_preferences.h @@ -16,8 +16,8 @@ namespace api { class RenderProcessPreferences : public mate::Wrappable { public: - static mate::Handle - ForAllWebContents(v8::Isolate* isolate); + static mate::Handle ForAllWebContents( + v8::Isolate* isolate); static void BuildPrototype(v8::Isolate* isolate, v8::Local prototype); diff --git a/atom/browser/api/atom_api_screen.cc b/atom/browser/api/atom_api_screen.cc index 2e94e05da35..60e7f78f0e7 100644 --- a/atom/browser/api/atom_api_screen.cc +++ b/atom/browser/api/atom_api_screen.cc @@ -25,9 +25,9 @@ namespace api { namespace { // Find an item in container according to its ID. -template +template typename T::iterator FindById(T* container, int id) { - auto predicate = [id] (const typename T::value_type& item) -> bool { + auto predicate = [id](const typename T::value_type& item) -> bool { return item.id() == id; }; return std::find_if(container->begin(), container->end(), predicate); @@ -96,15 +96,14 @@ void Screen::OnDisplayMetricsChanged(const display::Display& display, v8::Local Screen::Create(v8::Isolate* isolate) { if (!Browser::Get()->is_ready()) { isolate->ThrowException(v8::Exception::Error(mate::StringToV8( - isolate, - "Cannot require \"screen\" module before app is ready"))); + isolate, "Cannot require \"screen\" module before app is ready"))); return v8::Null(isolate); } display::Screen* screen = display::Screen::GetScreen(); if (!screen) { - isolate->ThrowException(v8::Exception::Error(mate::StringToV8( - isolate, "Failed to get screen information"))); + isolate->ThrowException(v8::Exception::Error( + mate::StringToV8(isolate, "Failed to get screen information"))); return v8::Null(isolate); } @@ -112,8 +111,8 @@ v8::Local Screen::Create(v8::Isolate* isolate) { } // static -void Screen::BuildPrototype( - v8::Isolate* isolate, v8::Local prototype) { +void Screen::BuildPrototype(v8::Isolate* isolate, + v8::Local prototype) { prototype->SetClassName(mate::StringToV8(isolate, "Screen")); mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) .SetMethod("getCursorScreenPoint", &Screen::GetCursorScreenPoint) @@ -134,8 +133,10 @@ namespace { using atom::api::Screen; -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary dict(isolate, exports); dict.Set("screen", Screen::Create(isolate)); diff --git a/atom/browser/api/atom_api_screen.h b/atom/browser/api/atom_api_screen.h index 1af170327d4..105c924e271 100644 --- a/atom/browser/api/atom_api_screen.h +++ b/atom/browser/api/atom_api_screen.h @@ -16,7 +16,7 @@ namespace gfx { class Point; class Rect; class Screen; -} +} // namespace gfx namespace atom { diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index cd0c2c138fb..e4d30dedb31 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -139,7 +139,7 @@ void SetUserAgentInIO(scoped_refptr getter, namespace mate { -template<> +template <> struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Local val, @@ -208,7 +208,7 @@ struct Converter { } }; -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, atom::VerifyRequestParams val) { @@ -244,17 +244,15 @@ class ResolveProxyHelper { scoped_refptr context_getter = browser_context->url_request_context_getter(); context_getter->GetNetworkTaskRunner()->PostTask( - FROM_HERE, - base::Bind(&ResolveProxyHelper::ResolveProxy, - base::Unretained(this), context_getter, url)); + FROM_HERE, base::Bind(&ResolveProxyHelper::ResolveProxy, + base::Unretained(this), context_getter, url)); } void OnResolveProxyCompleted(int result) { std::string proxy; if (result == net::OK) proxy = proxy_info_.ToPacString(); - original_thread_->PostTask(FROM_HERE, - base::Bind(callback_, proxy)); + original_thread_->PostTask(FROM_HERE, base::Bind(callback_, proxy)); delete this; } @@ -265,14 +263,13 @@ class ResolveProxyHelper { net::ProxyService* proxy_service = context_getter->GetURLRequestContext()->proxy_service(); - net::CompletionCallback completion_callback = - base::Bind(&ResolveProxyHelper::OnResolveProxyCompleted, - base::Unretained(this)); + net::CompletionCallback completion_callback = base::Bind( + &ResolveProxyHelper::OnResolveProxyCompleted, base::Unretained(this)); // Start the request. - int result = proxy_service->ResolveProxy( - url, "GET", &proxy_info_, completion_callback, &pac_req_, nullptr, - net::NetLogWithSource()); + int result = proxy_service->ResolveProxy(url, "GET", &proxy_info_, + completion_callback, &pac_req_, + nullptr, net::NetLogWithSource()); // Completed synchronously. if (result != net::ERR_IO_PENDING) @@ -291,10 +288,10 @@ class ResolveProxyHelper { void RunCallbackInUI(const base::Callback& callback) { BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); } -template +template void RunCallbackInUI(const base::Callback& callback, T... result) { - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, base::Bind(callback, result...)); + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, + base::Bind(callback, result...)); } // Callback of HttpCache::GetBackend. @@ -306,8 +303,8 @@ void OnGetBackend(disk_cache::Backend** backend_ptr, RunCallbackInUI(callback, result); } else if (backend_ptr && *backend_ptr) { if (action == Session::CacheAction::CLEAR) { - (*backend_ptr)->DoomAllEntries(base::Bind(&RunCallbackInUI, - callback)); + (*backend_ptr) + ->DoomAllEntries(base::Bind(&RunCallbackInUI, callback)); } else if (action == Session::CacheAction::STATS) { base::StringPairs stats; (*backend_ptr)->GetStats(&stats); @@ -348,8 +345,8 @@ void SetProxyInIO(scoped_refptr getter, const net::ProxyConfig& config, const base::Closure& callback) { auto proxy_service = getter->GetURLRequestContext()->proxy_service(); - proxy_service->ResetConfigService(base::WrapUnique( - new net::ProxyConfigServiceFixed(config))); + proxy_service->ResetConfigService( + base::WrapUnique(new net::ProxyConfigServiceFixed(config))); // Refetches and applies the new pac script if provided. proxy_service->ForceReloadProxyConfig(); RunCallbackInUI(callback); @@ -359,8 +356,8 @@ void SetCertVerifyProcInIO( const scoped_refptr& context_getter, const AtomCertVerifier::VerifyProc& proc) { auto request_context = context_getter->GetURLRequestContext(); - static_cast(request_context->cert_verifier())-> - SetVerifyProc(proc); + static_cast(request_context->cert_verifier()) + ->SetVerifyProc(proc); } void ClearHostResolverCacheInIO( @@ -437,9 +434,8 @@ void DownloadIdCallback(content::DownloadManager* download_manager, last_modified, offset, length, std::string(), content::DownloadItem::INTERRUPTED, content::DownloadDangerType::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, - content::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT, false, - base::Time(), false, - std::vector()); + content::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT, false, base::Time(), + false, std::vector()); } void SetDevToolsNetworkEmulationClientIdInIO( @@ -486,8 +482,8 @@ Session::Session(v8::Isolate* isolate, AtomBrowserContext* browser_context) : devtools_network_emulation_client_id_(base::GenerateGUID()), browser_context_(browser_context) { // Observe DownloadManager to get download notifications. - content::BrowserContext::GetDownloadManager(browser_context)-> - AddObserver(this); + content::BrowserContext::GetDownloadManager(browser_context) + ->AddObserver(this); new SessionPreferences(browser_context); @@ -500,8 +496,8 @@ Session::~Session() { content::BrowserThread::PostTask( content::BrowserThread::IO, FROM_HERE, base::BindOnce(ClearJobFactoryInIO, base::RetainedRef(getter))); - content::BrowserContext::GetDownloadManager(browser_context())-> - RemoveObserver(this); + content::BrowserContext::GetDownloadManager(browser_context()) + ->RemoveObserver(this); DestroyGlobalHandle(isolate(), cookies_); DestroyGlobalHandle(isolate(), web_request_); DestroyGlobalHandle(isolate(), protocol_); @@ -529,12 +525,12 @@ void Session::ResolveProxy(const GURL& url, ResolveProxyCallback callback) { new ResolveProxyHelper(browser_context(), url, callback); } -template +template void Session::DoCacheAction(const net::CompletionCallback& callback) { - BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, base::Bind(&DoCacheActionInIO, - WrapRefCounted(browser_context_->GetRequestContext()), - action, + WrapRefCounted(browser_context_->GetRequestContext()), action, callback)); } @@ -554,9 +550,8 @@ void Session::ClearStorageData(mate::Arguments* args) { } storage_partition->ClearData( options.storage_types, options.quota_types, options.origin, - content::StoragePartition::OriginMatcherFunction(), - base::Time(), base::Time::Max(), - base::Bind(&OnClearStorageDataDone, callback)); + content::StoragePartition::OriginMatcherFunction(), base::Time(), + base::Time::Max(), base::Bind(&OnClearStorageDataDone, callback)); } void Session::FlushStorageData() { @@ -575,8 +570,8 @@ void Session::SetProxy(const net::ProxyConfig& config, } void Session::SetDownloadPath(const base::FilePath& path) { - browser_context_->prefs()->SetFilePath( - prefs::kDownloadDefaultDirectory, path); + browser_context_->prefs()->SetFilePath(prefs::kDownloadDefaultDirectory, + path); } void Session::EnableNetworkEmulation(const mate::Dictionary& options) { @@ -623,10 +618,10 @@ void Session::SetCertVerifyProc(v8::Local val, return; } - BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, base::Bind(&SetCertVerifyProcInIO, - WrapRefCounted(browser_context_->GetRequestContext()), - proc)); + WrapRefCounted(browser_context_->GetRequestContext()), proc)); } void Session::SetPermissionRequestHandler(v8::Local val, @@ -645,7 +640,8 @@ void Session::ClearHostResolverCache(mate::Arguments* args) { base::Closure callback; args->GetNext(&callback); - BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, base::Bind(&ClearHostResolverCacheInIO, WrapRefCounted(browser_context_->GetRequestContext()), callback)); @@ -663,12 +659,13 @@ void Session::ClearAuthCache(mate::Arguments* args) { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&ClearAuthCacheInIO, - WrapRefCounted(browser_context_->GetRequestContext()), - options, callback)); + WrapRefCounted(browser_context_->GetRequestContext()), options, + callback)); } void Session::AllowNTLMCredentialsForDomains(const std::string& domains) { - BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, base::Bind(&AllowNTLMCredentialsForDomainsInIO, WrapRefCounted(browser_context_->GetRequestContext()), domains)); @@ -692,19 +689,16 @@ std::string Session::GetUserAgent() { return browser_context_->GetUserAgent(); } -void Session::GetBlobData( - const std::string& uuid, - const AtomBlobReader::CompletionCallback& callback) { +void Session::GetBlobData(const std::string& uuid, + const AtomBlobReader::CompletionCallback& callback) { if (callback.is_null()) return; - AtomBlobReader* blob_reader = - browser_context()->GetBlobReader(); - BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, - base::Bind(&AtomBlobReader::StartReading, - base::Unretained(blob_reader), - uuid, - callback)); + AtomBlobReader* blob_reader = browser_context()->GetBlobReader(); + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, + base::Bind(&AtomBlobReader::StartReading, base::Unretained(blob_reader), + uuid, callback)); } void Session::CreateInterruptedDownload(const mate::Dictionary& options) { @@ -776,14 +770,14 @@ v8::Local Session::WebRequest(v8::Isolate* isolate) { } // static -mate::Handle Session::CreateFrom( - v8::Isolate* isolate, AtomBrowserContext* browser_context) { +mate::Handle Session::CreateFrom(v8::Isolate* isolate, + AtomBrowserContext* browser_context) { auto existing = TrackableObject::FromWrappedClass(isolate, browser_context); if (existing) return mate::CreateHandle(isolate, static_cast(existing)); - auto handle = mate::CreateHandle( - isolate, new Session(isolate, browser_context)); + auto handle = + mate::CreateHandle(isolate, new Session(isolate, browser_context)); // The Sessions should never be garbage collected, since the common pattern is // to use partition strings, instead of using the Session object directly. @@ -795,7 +789,8 @@ mate::Handle Session::CreateFrom( // static mate::Handle Session::FromPartition( - v8::Isolate* isolate, const std::string& partition, + v8::Isolate* isolate, + const std::string& partition, const base::DictionaryValue& options) { scoped_refptr browser_context; if (partition.empty()) { @@ -852,8 +847,8 @@ namespace { using atom::api::Session; -v8::Local FromPartition( - const std::string& partition, mate::Arguments* args) { +v8::Local FromPartition(const std::string& partition, + mate::Arguments* args) { if (!atom::Browser::Get()->is_ready()) { args->ThrowError("Session can only be received when app is ready"); return v8::Null(args->isolate()); @@ -863,8 +858,10 @@ v8::Local FromPartition( return Session::FromPartition(args->isolate(), partition, options).ToV8(); } -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary dict(isolate, exports); dict.Set("Session", Session::GetConstructor(isolate)->GetFunction()); diff --git a/atom/browser/api/atom_api_session.h b/atom/browser/api/atom_api_session.h index d56c2400d4d..1059e9856af 100644 --- a/atom/browser/api/atom_api_session.h +++ b/atom/browser/api/atom_api_session.h @@ -24,7 +24,7 @@ class FilePath; namespace mate { class Arguments; class Dictionary; -} +} // namespace mate namespace net { class ProxyConfig; @@ -36,8 +36,8 @@ class AtomBrowserContext; namespace api { -class Session: public mate::TrackableObject, - public content::DownloadManager::Observer { +class Session : public mate::TrackableObject, + public content::DownloadManager::Observer { public: using ResolveProxyCallback = base::Callback; @@ -47,12 +47,13 @@ class Session: public mate::TrackableObject, }; // Gets or creates Session from the |browser_context|. - static mate::Handle CreateFrom( - v8::Isolate* isolate, AtomBrowserContext* browser_context); + static mate::Handle CreateFrom(v8::Isolate* isolate, + AtomBrowserContext* browser_context); // Gets the Session of |partition|. static mate::Handle FromPartition( - v8::Isolate* isolate, const std::string& partition, + v8::Isolate* isolate, + const std::string& partition, const base::DictionaryValue& options = base::DictionaryValue()); AtomBrowserContext* browser_context() const { return browser_context_.get(); } @@ -63,7 +64,7 @@ class Session: public mate::TrackableObject, // Methods. void ResolveProxy(const GURL& url, ResolveProxyCallback callback); - template + template void DoCacheAction(const net::CompletionCallback& callback); void ClearStorageData(mate::Arguments* args); void FlushStorageData(); diff --git a/atom/browser/api/atom_api_system_preferences.cc b/atom/browser/api/atom_api_system_preferences.cc index 3eeba8a7eed..0ce291e78d1 100644 --- a/atom/browser/api/atom_api_system_preferences.cc +++ b/atom/browser/api/atom_api_system_preferences.cc @@ -45,7 +45,8 @@ mate::Handle SystemPreferences::Create( // static void SystemPreferences::BuildPrototype( - v8::Isolate* isolate, v8::Local prototype) { + v8::Isolate* isolate, + v8::Local prototype) { prototype->SetClassName(mate::StringToV8(isolate, "SystemPreferences")); mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) #if defined(OS_WIN) @@ -53,8 +54,7 @@ void SystemPreferences::BuildPrototype( .SetMethod("isAeroGlassEnabled", &SystemPreferences::IsAeroGlassEnabled) .SetMethod("getColor", &SystemPreferences::GetColor) #elif defined(OS_MACOSX) - .SetMethod("postNotification", - &SystemPreferences::PostNotification) + .SetMethod("postNotification", &SystemPreferences::PostNotification) .SetMethod("subscribeNotification", &SystemPreferences::SubscribeNotification) .SetMethod("unsubscribeNotification", @@ -91,8 +91,10 @@ namespace { using atom::api::SystemPreferences; -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary dict(isolate, exports); dict.Set("systemPreferences", SystemPreferences::Create(isolate)); diff --git a/atom/browser/api/atom_api_system_preferences.h b/atom/browser/api/atom_api_system_preferences.h index 057543dadeb..bfd64e80159 100644 --- a/atom/browser/api/atom_api_system_preferences.h +++ b/atom/browser/api/atom_api_system_preferences.h @@ -36,10 +36,11 @@ enum NotificationCenterKind { class SystemPreferences : public mate::EventEmitter #if defined(OS_WIN) - , public BrowserObserver - , public gfx::SysColorChangeListener + , + public BrowserObserver, + public gfx::SysColorChangeListener #endif - { +{ public: static mate::Handle Create(v8::Isolate* isolate); @@ -49,10 +50,10 @@ class SystemPreferences : public mate::EventEmitter #if defined(OS_WIN) bool IsAeroGlassEnabled(); - typedef HRESULT (STDAPICALLTYPE *DwmGetColorizationColor)(DWORD *, BOOL *); + typedef HRESULT(STDAPICALLTYPE* DwmGetColorizationColor)(DWORD*, BOOL*); DwmGetColorizationColor dwmGetColorizationColor = - (DwmGetColorizationColor) GetProcAddress(LoadLibraryW(L"dwmapi.dll"), - "DwmGetColorizationColor"); + (DwmGetColorizationColor)GetProcAddress(LoadLibraryW(L"dwmapi.dll"), + "DwmGetColorizationColor"); std::string GetAccentColor(); std::string GetColor(const std::string& color, mate::Arguments* args); @@ -66,8 +67,8 @@ class SystemPreferences : public mate::EventEmitter void OnFinishLaunching(const base::DictionaryValue& launch_info) override; #elif defined(OS_MACOSX) - using NotificationCallback = base::Callback< - void(const std::string&, const base::DictionaryValue&)>; + using NotificationCallback = + base::Callback; void PostNotification(const std::string& name, const base::DictionaryValue& user_info); @@ -80,9 +81,9 @@ class SystemPreferences : public mate::EventEmitter const NotificationCallback& callback); void UnsubscribeLocalNotification(int request_id); void PostWorkspaceNotification(const std::string& name, - const base::DictionaryValue& user_info); + const base::DictionaryValue& user_info); int SubscribeWorkspaceNotification(const std::string& name, - const NotificationCallback& callback); + const NotificationCallback& callback); void UnsubscribeWorkspaceNotification(int request_id); v8::Local GetUserDefault(const std::string& name, const std::string& type); @@ -113,11 +114,15 @@ class SystemPreferences : public mate::EventEmitter private: #if defined(OS_WIN) // Static callback invoked when a message comes in to our messaging window. - static LRESULT CALLBACK - WndProcStatic(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); + static LRESULT CALLBACK WndProcStatic(HWND hwnd, + UINT message, + WPARAM wparam, + LPARAM lparam); - LRESULT CALLBACK - WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); + LRESULT CALLBACK WndProc(HWND hwnd, + UINT message, + WPARAM wparam, + LPARAM lparam); // The window class of |window_|. ATOM atom_; diff --git a/atom/browser/api/atom_api_system_preferences_win.cc b/atom/browser/api/atom_api_system_preferences_win.cc index f9bbd294ee5..b3fd74d59d9 100644 --- a/atom/browser/api/atom_api_system_preferences_win.cc +++ b/atom/browser/api/atom_api_system_preferences_win.cc @@ -17,7 +17,7 @@ namespace atom { namespace { const wchar_t kSystemPreferencesWindowClass[] = - L"Electron_SystemPreferencesHostWindow"; + L"Electron_SystemPreferencesHostWindow"; } // namespace @@ -130,9 +130,8 @@ void SystemPreferences::InitializeWindow() { WNDCLASSEX window_class; base::win::InitializeWindowClass( kSystemPreferencesWindowClass, - &base::win::WrappedWindowProc, - 0, 0, 0, NULL, NULL, NULL, NULL, NULL, - &window_class); + &base::win::WrappedWindowProc, 0, 0, 0, + NULL, NULL, NULL, NULL, NULL, &window_class); instance_ = window_class.hInstance; atom_ = RegisterClassEx(&window_class); @@ -140,16 +139,16 @@ void SystemPreferences::InitializeWindow() { // colorization color. Create a hidden WS_POPUP window instead of an // HWND_MESSAGE window, because only top-level windows such as popups can // receive broadcast messages like "WM_DWMCOLORIZATIONCOLORCHANGED". - window_ = CreateWindow(MAKEINTATOM(atom_), - 0, WS_POPUP, 0, 0, 0, 0, 0, 0, instance_, 0); + window_ = CreateWindow(MAKEINTATOM(atom_), 0, WS_POPUP, 0, 0, 0, 0, 0, 0, + instance_, 0); gfx::CheckWindowCreated(window_); gfx::SetWindowUserData(window_, this); } LRESULT CALLBACK SystemPreferences::WndProcStatic(HWND hwnd, - UINT message, - WPARAM wparam, - LPARAM lparam) { + UINT message, + WPARAM wparam, + LPARAM lparam) { SystemPreferences* msg_wnd = reinterpret_cast( GetWindowLongPtr(hwnd, GWLP_USERDATA)); if (msg_wnd) @@ -159,11 +158,11 @@ LRESULT CALLBACK SystemPreferences::WndProcStatic(HWND hwnd, } LRESULT CALLBACK SystemPreferences::WndProc(HWND hwnd, - UINT message, - WPARAM wparam, - LPARAM lparam) { + UINT message, + WPARAM wparam, + LPARAM lparam) { if (message == WM_DWMCOLORIZATIONCOLORCHANGED) { - DWORD new_color = (DWORD) wparam; + DWORD new_color = (DWORD)wparam; std::string new_color_string = hexColorDWORDToRGBA(new_color); if (new_color_string != current_color_) { Emit("accent-color-changed", hexColorDWORDToRGBA(new_color)); diff --git a/atom/browser/api/atom_api_top_level_window.cc b/atom/browser/api/atom_api_top_level_window.cc index 17d941e73b5..735835c87cc 100644 --- a/atom/browser/api/atom_api_top_level_window.cc +++ b/atom/browser/api/atom_api_top_level_window.cc @@ -34,9 +34,10 @@ #if defined(OS_WIN) namespace mate { -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Handle val, + static bool FromV8(v8::Isolate* isolate, + v8::Handle val, atom::TaskbarHost::ThumbarButton* out) { mate::Dictionary dict; if (!ConvertFromV8(isolate, val, &dict)) @@ -82,16 +83,14 @@ TopLevelWindow::TopLevelWindow(v8::Isolate* isolate, mate::Dictionary web_preferences; bool offscreen; if (options.Get(options::kWebPreferences, &web_preferences) && - web_preferences.Get("offscreen", &offscreen) && - offscreen) { + web_preferences.Get("offscreen", &offscreen) && offscreen) { const_cast(options).Set(options::kFrame, false); } #endif // Creates NativeWindow. window_.reset(NativeWindow::Create( - options, - parent.IsEmpty() ? nullptr : parent->window_.get())); + options, parent.IsEmpty() ? nullptr : parent->window_.get())); window_->AddObserver(this); #if defined(TOOLKIT_VIEWS) @@ -227,8 +226,9 @@ void TopLevelWindow::OnExecuteWindowsCommand(const std::string& command_name) { Emit("app-command", command_name); } -void TopLevelWindow::OnTouchBarItemResult(const std::string& item_id, - const base::DictionaryValue& details) { +void TopLevelWindow::OnTouchBarItemResult( + const std::string& item_id, + const base::DictionaryValue& details) { Emit("-touch-bar-interaction", item_id, details); } @@ -238,8 +238,8 @@ void TopLevelWindow::OnNewWindowForTab() { #if defined(OS_WIN) void TopLevelWindow::OnWindowMessage(UINT message, - WPARAM w_param, - LPARAM l_param) { + WPARAM w_param, + LPARAM l_param) { if (IsWindowMessageHooked(message)) { messages_callback_map_[message].Run( ToBuffer(isolate(), static_cast(&w_param), sizeof(WPARAM)), @@ -334,7 +334,7 @@ gfx::Rect TopLevelWindow::GetBounds() { } void TopLevelWindow::SetContentBounds(const gfx::Rect& bounds, - mate::Arguments* args) { + mate::Arguments* args) { bool animate = false; args->GetNext(&animate); window_->SetContentBounds(bounds, animate); @@ -358,8 +358,9 @@ std::vector TopLevelWindow::GetSize() { return result; } -void TopLevelWindow::SetContentSize(int width, int height, - mate::Arguments* args) { +void TopLevelWindow::SetContentSize(int width, + int height, + mate::Arguments* args) { bool animate = false; args->GetNext(&animate); window_->SetContentSize(gfx::Size(width, height), animate); @@ -580,16 +581,15 @@ void TopLevelWindow::SetMenu(v8::Isolate* isolate, v8::Local value) { mate::Handle menu; if (value->IsObject() && mate::V8ToString(value->ToObject()->GetConstructorName()) == "Menu" && - mate::ConvertFromV8(isolate, value, &menu) && - !menu.IsEmpty()) { + mate::ConvertFromV8(isolate, value, &menu) && !menu.IsEmpty()) { menu_.Reset(isolate, menu.ToV8()); window_->SetMenu(menu->model()); } else if (value->IsNull()) { menu_.Reset(); window_->SetMenu(nullptr); } else { - isolate->ThrowException(v8::Exception::TypeError( - mate::StringToV8(isolate, "Invalid Menu"))); + isolate->ThrowException( + v8::Exception::TypeError(mate::StringToV8(isolate, "Invalid Menu"))); } } @@ -789,19 +789,19 @@ bool TopLevelWindow::SetThumbarButtons(mate::Arguments* args) { #if defined(TOOLKIT_VIEWS) void TopLevelWindow::SetIcon(mate::Handle icon) { #if defined(OS_WIN) - static_cast(window_.get())->SetIcon( - icon->GetHICON(GetSystemMetrics(SM_CXSMICON)), - icon->GetHICON(GetSystemMetrics(SM_CXICON))); + static_cast(window_.get()) + ->SetIcon(icon->GetHICON(GetSystemMetrics(SM_CXSMICON)), + icon->GetHICON(GetSystemMetrics(SM_CXICON))); #elif defined(USE_X11) - static_cast(window_.get())->SetIcon( - icon->image().AsImageSkia()); + static_cast(window_.get()) + ->SetIcon(icon->image().AsImageSkia()); #endif } #endif #if defined(OS_WIN) bool TopLevelWindow::HookWindowMessage(UINT message, - const MessageCallback& callback) { + const MessageCallback& callback) { messages_callback_map_[message] = callback; return true; } @@ -846,10 +846,9 @@ void TopLevelWindow::SetAppDetails(const mate::Dictionary& options) { options.Get("relaunchCommand", &relaunch_command); options.Get("relaunchDisplayName", &relaunch_display_name); - ui::win::SetAppDetailsForWindow( - app_id, app_icon_path, app_icon_index, - relaunch_command, relaunch_display_name, - window_->GetAcceleratedWidget()); + ui::win::SetAppDetailsForWindow(app_id, app_icon_path, app_icon_index, + relaunch_command, relaunch_display_name, + window_->GetAcceleratedWidget()); } #endif @@ -906,7 +905,7 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate, .SetMethod("hide", &TopLevelWindow::Hide) .SetMethod("isVisible", &TopLevelWindow::IsVisible) .SetMethod("isEnabled", &TopLevelWindow::IsEnabled) - .SetMethod("setEnabled", & TopLevelWindow::SetEnabled) + .SetMethod("setEnabled", &TopLevelWindow::SetEnabled) .SetMethod("maximize", &TopLevelWindow::Maximize) .SetMethod("unmaximize", &TopLevelWindow::Unmaximize) .SetMethod("isMaximized", &TopLevelWindow::IsMaximized) @@ -932,7 +931,7 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate, .SetMethod("isResizable", &TopLevelWindow::IsResizable) .SetMethod("setMovable", &TopLevelWindow::SetMovable) #if defined(OS_WIN) || defined(OS_MACOSX) - .SetMethod("moveTop" , &TopLevelWindow::MoveTop) + .SetMethod("moveTop", &TopLevelWindow::MoveTop) #endif .SetMethod("isMovable", &TopLevelWindow::IsMovable) .SetMethod("setMinimizable", &TopLevelWindow::SetMinimizable) @@ -1036,8 +1035,10 @@ namespace { using atom::api::TopLevelWindow; -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { v8::Isolate* isolate = context->GetIsolate(); TopLevelWindow::SetConstructor(isolate, base::Bind(&TopLevelWindow::New)); diff --git a/atom/browser/api/atom_api_top_level_window.h b/atom/browser/api/atom_api_top_level_window.h index 86e57a5ecea..ef140f6e8b2 100644 --- a/atom/browser/api/atom_api_top_level_window.h +++ b/atom/browser/api/atom_api_top_level_window.h @@ -68,9 +68,9 @@ class TopLevelWindow : public mate::TrackableObject, void OnTouchBarItemResult(const std::string& item_id, const base::DictionaryValue& details) override; void OnNewWindowForTab() override; - #if defined(OS_WIN) +#if defined(OS_WIN) void OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) override; - #endif +#endif // Public APIs of NativeWindow. void Close(); @@ -107,9 +107,9 @@ class TopLevelWindow : public mate::TrackableObject, void SetResizable(bool resizable); bool IsResizable(); void SetMovable(bool movable); - #if defined(OS_WIN) || defined(OS_MACOSX) +#if defined(OS_WIN) || defined(OS_MACOSX) void MoveTop(); - #endif +#endif bool IsMovable(); void SetMinimizable(bool minimizable); bool IsMinimizable(); @@ -184,8 +184,8 @@ class TopLevelWindow : public mate::TrackableObject, void SetIcon(mate::Handle icon); #endif #if defined(OS_WIN) - typedef base::Callback, - v8::Local)> MessageCallback; + typedef base::Callback, v8::Local)> + MessageCallback; bool HookWindowMessage(UINT message, const MessageCallback& callback); bool IsWindowMessageHooked(UINT message); void UnhookWindowMessage(UINT message); diff --git a/atom/browser/api/atom_api_tray.cc b/atom/browser/api/atom_api_tray.cc index 6a032e20279..08739552f3a 100644 --- a/atom/browser/api/atom_api_tray.cc +++ b/atom/browser/api/atom_api_tray.cc @@ -20,9 +20,10 @@ namespace mate { -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, atom::TrayIcon::HighlightMode* out) { std::string mode; if (ConvertFromV8(isolate, val, &mode)) { @@ -54,12 +55,12 @@ struct Converter { }; } // namespace mate - namespace atom { namespace api { -Tray::Tray(v8::Isolate* isolate, v8::Local wrapper, +Tray::Tray(v8::Isolate* isolate, + v8::Local wrapper, mate::Handle image) : tray_icon_(TrayIcon::Create()) { SetImage(isolate, image); @@ -70,8 +71,8 @@ Tray::Tray(v8::Isolate* isolate, v8::Local wrapper, Tray::~Tray() { // Destroy the native tray in next tick. - base::ThreadTaskRunnerHandle::Get()->DeleteSoon( - FROM_HERE, tray_icon_.release()); + base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, + tray_icon_.release()); } // static @@ -180,8 +181,7 @@ void Tray::DisplayBalloon(mate::Arguments* args, mate::Handle icon; options.Get("icon", &icon); base::string16 title, content; - if (!options.Get("title", &title) || - !options.Get("content", &content)) { + if (!options.Get("title", &title) || !options.Get("content", &content)) { args->ThrowError("'title' and 'content' must be defined"); return; } @@ -191,8 +191,8 @@ void Tray::DisplayBalloon(mate::Arguments* args, icon.IsEmpty() ? NULL : icon->GetHICON(GetSystemMetrics(SM_CXSMICON)), title, content); #else - tray_icon_->DisplayBalloon( - icon.IsEmpty() ? gfx::Image() : icon->image(), title, content); + tray_icon_->DisplayBalloon(icon.IsEmpty() ? gfx::Image() : icon->image(), + title, content); #endif } @@ -234,13 +234,14 @@ void Tray::BuildPrototype(v8::Isolate* isolate, } // namespace atom - namespace { using atom::api::Tray; -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { v8::Isolate* isolate = context->GetIsolate(); Tray::SetConstructor(isolate, base::Bind(&Tray::New)); diff --git a/atom/browser/api/atom_api_tray.h b/atom/browser/api/atom_api_tray.h index e1445161a6d..94bcd8adbd5 100644 --- a/atom/browser/api/atom_api_tray.h +++ b/atom/browser/api/atom_api_tray.h @@ -21,7 +21,7 @@ class Image; namespace mate { class Arguments; class Dictionary; -} +} // namespace mate namespace atom { @@ -32,8 +32,7 @@ namespace api { class Menu; class NativeImage; -class Tray : public mate::TrackableObject, - public TrayIconObserver { +class Tray : public mate::TrackableObject, public TrayIconObserver { public: static mate::WrappableBase* New(mate::Handle image, mate::Arguments* args); @@ -42,7 +41,8 @@ class Tray : public mate::TrackableObject, v8::Local prototype); protected: - Tray(v8::Isolate* isolate, v8::Local wrapper, + Tray(v8::Isolate* isolate, + v8::Local wrapper, mate::Handle image); ~Tray() override; diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 6c3b6796b27..d91d2d02df8 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -108,7 +108,7 @@ struct PrintSettings { namespace mate { -template<> +template <> struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Local val, @@ -130,9 +130,10 @@ struct Converter { } }; -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, PrintSettings* out) { mate::Dictionary dict; if (!ConvertFromV8(isolate, val, &dict)) @@ -144,7 +145,7 @@ struct Converter { } }; -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, const printing::PrinterBasicInfo& val) { @@ -158,7 +159,7 @@ struct Converter { } }; -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, WindowOpenDisposition val) { @@ -187,9 +188,10 @@ struct Converter { } }; -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, content::SavePageType* out) { std::string save_type; if (!ConvertFromV8(isolate, val, &save_type)) @@ -208,25 +210,39 @@ struct Converter { } }; -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, atom::api::WebContents::Type val) { using Type = atom::api::WebContents::Type; std::string type = ""; switch (val) { - case Type::BACKGROUND_PAGE: type = "backgroundPage"; break; - case Type::BROWSER_WINDOW: type = "window"; break; - case Type::BROWSER_VIEW: type = "browserView"; break; - case Type::REMOTE: type = "remote"; break; - case Type::WEB_VIEW: type = "webview"; break; - case Type::OFF_SCREEN: type = "offscreen"; break; - default: break; + case Type::BACKGROUND_PAGE: + type = "backgroundPage"; + break; + case Type::BROWSER_WINDOW: + type = "window"; + break; + case Type::BROWSER_VIEW: + type = "browserView"; + break; + case Type::REMOTE: + type = "remote"; + break; + case Type::WEB_VIEW: + type = "webview"; + break; + case Type::OFF_SCREEN: + type = "offscreen"; + break; + default: + break; } return mate::ConvertToV8(isolate, type); } - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, atom::api::WebContents::Type* out) { using Type = atom::api::WebContents::Type; std::string type; @@ -251,7 +267,6 @@ struct Converter { } // namespace mate - namespace atom { namespace api { @@ -377,17 +392,17 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options) content::WebContents* web_contents; if (IsGuest()) { scoped_refptr site_instance = - content::SiteInstance::CreateForURL( - session->browser_context(), GURL("chrome-guest://fake-host")); - content::WebContents::CreateParams params( - session->browser_context(), site_instance); + content::SiteInstance::CreateForURL(session->browser_context(), + GURL("chrome-guest://fake-host")); + content::WebContents::CreateParams params(session->browser_context(), + site_instance); guest_delegate_.reset(new WebViewGuestDelegate); params.guest_delegate = guest_delegate_.get(); #if defined(ENABLE_OSR) if (embedder_ && embedder_->IsOffScreen()) { - auto* view = new OffScreenWebContentsView(false, - base::Bind(&WebContents::OnPaint, base::Unretained(this))); + auto* view = new OffScreenWebContentsView( + false, base::Bind(&WebContents::OnPaint, base::Unretained(this))); params.view = view; params.delegate_view = view; @@ -403,8 +418,8 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options) options.Get("transparent", &transparent); content::WebContents::CreateParams params(session->browser_context()); - auto* view = new OffScreenWebContentsView(transparent, - base::Bind(&WebContents::OnPaint, base::Unretained(this))); + auto* view = new OffScreenWebContentsView( + transparent, base::Bind(&WebContents::OnPaint, base::Unretained(this))); params.view = view; params.delegate_view = view; @@ -429,7 +444,7 @@ void WebContents::InitZoomController(content::WebContents* web_contents, } void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate, - content::WebContents *web_contents, + content::WebContents* web_contents, mate::Handle session, const mate::Dictionary& options) { Observe(web_contents); @@ -442,7 +457,8 @@ void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate, #if defined(OS_LINUX) || defined(OS_WIN) // Update font settings. - CR_DEFINE_STATIC_LOCAL(const gfx::FontRenderParams, params, + CR_DEFINE_STATIC_LOCAL( + const gfx::FontRenderParams, params, (gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), nullptr))); prefs->should_antialias_text = params.antialiasing; prefs->use_subpixel_positioning = params.subpixel_positioning; @@ -541,13 +557,12 @@ void WebContents::OnCreateWindow( Emit("new-window", target_url, frame_name, disposition, features); } -void WebContents::WebContentsCreated( - content::WebContents* source_contents, - int opener_render_process_id, - int opener_render_frame_id, - const std::string& frame_name, - const GURL& target_url, - content::WebContents* new_contents) { +void WebContents::WebContentsCreated(content::WebContents* source_contents, + int opener_render_process_id, + int opener_render_frame_id, + const std::string& frame_name, + const GURL& target_url, + content::WebContents* new_contents) { v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); auto api_web_contents = CreateFrom(isolate(), new_contents, BROWSER_WINDOW); @@ -565,8 +580,8 @@ void WebContents::AddNewContents(content::WebContents* source, v8::HandleScope handle_scope(isolate()); auto api_web_contents = CreateFrom(isolate(), new_contents); if (Emit("-add-new-contents", api_web_contents, disposition, user_gesture, - initial_rect.x(), initial_rect.y(), initial_rect.width(), - initial_rect.height())) { + initial_rect.x(), initial_rect.y(), initial_rect.width(), + initial_rect.height())) { api_web_contents->DestroyWebContents(true /* async */); } } @@ -660,8 +675,7 @@ content::KeyboardEventProcessingResult WebContents::PreHandleKeyboardEvent( void WebContents::EnterFullscreenModeForTab(content::WebContents* source, const GURL& origin) { - auto permission_helper = - WebContentsPermissionHelper::FromWebContents(source); + auto permission_helper = WebContentsPermissionHelper::FromWebContents(source); auto callback = base::Bind(&WebContents::OnEnterFullscreenModeForTab, base::Unretained(this), source, origin); permission_helper->RequestFullscreenPermission(callback); @@ -695,8 +709,7 @@ void WebContents::RendererResponsive(content::WebContents* source) { bool WebContents::HandleContextMenu(const content::ContextMenuParams& params) { if (params.custom_context.is_pepper_menu) { - Emit("pepper-context-menu", - std::make_pair(params, web_contents()), + Emit("pepper-context-menu", std::make_pair(params, web_contents()), base::Bind(&content::WebContents::NotifyContextMenuClosed, base::Unretained(web_contents()), params.custom_context)); } else { @@ -731,10 +744,9 @@ void WebContents::FindReply(content::WebContents* web_contents, Emit("found-in-page", result); } -bool WebContents::CheckMediaAccessPermission( - content::WebContents* web_contents, - const GURL& security_origin, - content::MediaStreamType type) { +bool WebContents::CheckMediaAccessPermission(content::WebContents* web_contents, + const GURL& security_origin, + content::MediaStreamType type) { return true; } @@ -747,10 +759,9 @@ void WebContents::RequestMediaAccessPermission( permission_helper->RequestMediaAccessPermission(request, callback); } -void WebContents::RequestToLockMouse( - content::WebContents* web_contents, - bool user_gesture, - bool last_unlocked_by_target) { +void WebContents::RequestToLockMouse(content::WebContents* web_contents, + bool user_gesture, + bool last_unlocked_by_target) { auto permission_helper = WebContentsPermissionHelper::FromWebContents(web_contents); permission_helper->RequestPointerLockPermission(user_gesture); @@ -764,8 +775,7 @@ std::unique_ptr WebContents::RunBluetoothChooser( return std::move(bluetooth_chooser); } -content::JavaScriptDialogManager* -WebContents::GetJavaScriptDialogManager( +content::JavaScriptDialogManager* WebContents::GetJavaScriptDialogManager( content::WebContents* source) { if (!dialog_manager_) dialog_manager_.reset(new AtomJavaScriptDialogManager(this)); @@ -861,26 +871,17 @@ void WebContents::DidGetResourceResponseStart( (details.resource_type == content::RESOURCE_TYPE_MAIN_FRAME || details.resource_type == content::RESOURCE_TYPE_SUB_FRAME)) return; - Emit("did-get-response-details", - details.socket_address.IsEmpty(), - details.url, - details.original_url, - details.http_response_code, - details.method, - details.referrer, - details.headers.get(), + Emit("did-get-response-details", details.socket_address.IsEmpty(), + details.url, details.original_url, details.http_response_code, + details.method, details.referrer, details.headers.get(), ResourceTypeToString(details.resource_type)); } void WebContents::DidGetRedirectForResourceRequest( const content::ResourceRedirectDetails& details) { - Emit("did-get-redirect-request", - details.url, - details.new_url, + Emit("did-get-redirect-request", details.url, details.new_url, (details.resource_type == content::RESOURCE_TYPE_MAIN_FRAME), - details.http_response_code, - details.method, - details.referrer, + details.http_response_code, details.method, details.referrer, details.headers.get()); } @@ -953,8 +954,8 @@ void WebContents::DevToolsOpened() { // Set inspected tabID. base::Value tab_id(ID()); - managed_web_contents()->CallClientFunction( - "DevToolsAPI.setInspectedTabId", &tab_id, nullptr, nullptr); + managed_web_contents()->CallClientFunction("DevToolsAPI.setInspectedTabId", + &tab_id, nullptr, nullptr); // Inherit owner window in devtools when it doesn't have one. auto* devtools = managed_web_contents()->GetDevToolsWebContents(); @@ -979,8 +980,8 @@ void WebContents::ShowAutofillPopup(content::RenderFrameHost* frame_host, const std::vector& values, const std::vector& labels) { bool offscreen = IsOffScreen() || (embedder_ && embedder_->IsOffScreen()); - CommonWebContentsDelegate::ShowAutofillPopup( - offscreen, frame_host, bounds, values, labels); + CommonWebContentsDelegate::ShowAutofillPopup(offscreen, frame_host, bounds, + values, labels); } #endif @@ -1041,8 +1042,7 @@ void WebContents::WebContentsDestroyed() { Emit("destroyed"); // Destroy the native class in next tick. - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, GetDestroyClosure()); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, GetDestroyClosure()); } void WebContents::NavigationEntryCommitted( @@ -1082,11 +1082,9 @@ bool WebContents::Equal(const WebContents* web_contents) const { void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) { if (!url.is_valid() || url.spec().size() > url::kMaxURLChars) { - Emit("did-fail-load", - static_cast(net::ERR_INVALID_URL), + Emit("did-fail-load", static_cast(net::ERR_INVALID_URL), net::ErrorToShortString(net::ERR_INVALID_URL), - url.possibly_invalid_spec(), - true); + url.possibly_invalid_spec(), true); return; } @@ -1147,7 +1145,7 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) { void WebContents::DownloadURL(const GURL& url) { auto browser_context = web_contents()->GetBrowserContext(); auto download_manager = - content::BrowserContext::GetDownloadManager(browser_context); + content::BrowserContext::GetDownloadManager(browser_context); download_manager->DownloadUrl( content::DownloadUrlParameters::CreateForWebContentsMainFrame( @@ -1194,8 +1192,7 @@ void WebContents::GoToOffset(int offset) { } const std::string WebContents::GetWebRTCIPHandlingPolicy() const { - return web_contents()-> - GetMutableRendererPrefs()->webrtc_ip_handling_policy; + return web_contents()->GetMutableRendererPrefs()->webrtc_ip_handling_policy; } void WebContents::SetWebRTCIPHandlingPolicy( @@ -1203,7 +1200,7 @@ void WebContents::SetWebRTCIPHandlingPolicy( if (GetWebRTCIPHandlingPolicy() == webrtc_ip_handling_policy) return; web_contents()->GetMutableRendererPrefs()->webrtc_ip_handling_policy = - webrtc_ip_handling_policy; + webrtc_ip_handling_policy; content::RenderViewHost* host = web_contents()->GetRenderViewHost(); if (host) @@ -1345,8 +1342,7 @@ void WebContents::InspectServiceWorker() { } } -void WebContents::HasServiceWorker( - const base::Callback& callback) { +void WebContents::HasServiceWorker(const base::Callback& callback) { auto context = GetServiceWorkerContext(web_contents()); if (!context) return; @@ -1392,7 +1388,7 @@ bool WebContents::IsAudioMuted() { } void WebContents::Print(mate::Arguments* args) { - PrintSettings settings = { false, false, base::string16() }; + PrintSettings settings = {false, false, base::string16()}; if (args->Length() >= 1 && !args->GetNext(&settings)) { args->ThrowError(); return; @@ -1407,10 +1403,9 @@ void WebContents::Print(mate::Arguments* args) { } print_view_manager_basic_ptr->SetCallback(callback); } - print_view_manager_basic_ptr->PrintNow(web_contents()->GetMainFrame(), - settings.silent, - settings.print_background, - settings.device_name); + print_view_manager_basic_ptr->PrintNow( + web_contents()->GetMainFrame(), settings.silent, + settings.print_background, settings.device_name); } std::vector WebContents::GetPrinterList() { @@ -1423,8 +1418,8 @@ std::vector WebContents::GetPrinterList() { void WebContents::PrintToPDF(const base::DictionaryValue& setting, const PrintToPDFCallback& callback) { - printing::PrintPreviewMessageHandler::FromWebContents(web_contents())-> - PrintToPDF(setting, callback); + printing::PrintPreviewMessageHandler::FromWebContents(web_contents()) + ->PrintToPDF(setting, callback); } void WebContents::AddWorkSpace(mate::Arguments* args, @@ -1529,7 +1524,8 @@ void WebContents::Focus() { #if !defined(OS_MACOSX) bool WebContents::IsFocused() const { auto view = web_contents()->GetRenderWidgetHostView(); - if (!view) return false; + if (!view) + return false; if (GetType() != BACKGROUND_PAGE) { auto window = web_contents()->GetNativeView()->GetToplevelWindow(); @@ -1559,12 +1555,12 @@ bool WebContents::SendIPCMessage(bool all_frames, void WebContents::SendInputEvent(v8::Isolate* isolate, v8::Local input_event) { const auto view = static_cast( - web_contents()->GetRenderWidgetHostView()); + web_contents()->GetRenderWidgetHostView()); if (!view) return; - blink::WebInputEvent::Type type = mate::GetWebInputEventType(isolate, - input_event); + blink::WebInputEvent::Type type = + mate::GetWebInputEventType(isolate, input_event); if (blink::WebInputEvent::IsMouseEventType(type)) { blink::WebMouseEvent mouse_event; if (mate::ConvertFromV8(isolate, input_event, &mouse_event)) { @@ -1574,8 +1570,7 @@ void WebContents::SendInputEvent(v8::Isolate* isolate, } else if (blink::WebInputEvent::IsKeyboardEventType(type)) { content::NativeWebKeyboardEvent keyboard_event( blink::WebKeyboardEvent::kRawKeyDown, - blink::WebInputEvent::kNoModifiers, - ui::EventTimeForNow()); + blink::WebInputEvent::kNoModifiers, ui::EventTimeForNow()); if (mate::ConvertFromV8(isolate, input_event, &keyboard_event)) { view->ProcessKeyboardEvent(keyboard_event, ui::LatencyInfo()); return; @@ -1588,8 +1583,8 @@ void WebContents::SendInputEvent(v8::Isolate* isolate, } } - isolate->ThrowException(v8::Exception::Error(mate::StringToV8( - isolate, "Invalid event object"))); + isolate->ThrowException( + v8::Exception::Error(mate::StringToV8(isolate, "Invalid event object"))); } void WebContents::BeginFrameSubscription(mate::Arguments* args) { @@ -1604,8 +1599,8 @@ void WebContents::BeginFrameSubscription(mate::Arguments* args) { const auto view = web_contents()->GetRenderWidgetHostView(); if (view) { - std::unique_ptr frame_subscriber(new FrameSubscriber( - isolate(), view, callback, only_dirty)); + std::unique_ptr frame_subscriber( + new FrameSubscriber(isolate(), view, callback, only_dirty)); view->BeginFrameSubscription(std::move(frame_subscriber)); } } @@ -1658,8 +1653,8 @@ void WebContents::CapturePage(mate::Arguments* args) { base::Callback callback; if (!(args->Length() == 1 && args->GetNext(&callback)) && - !(args->Length() == 2 && args->GetNext(&rect) - && args->GetNext(&callback))) { + !(args->Length() == 2 && args->GetNext(&rect) && + args->GetNext(&callback))) { args->ThrowError(); return; } @@ -1671,22 +1666,21 @@ void WebContents::CapturePage(mate::Arguments* args) { } // Capture full page if user doesn't specify a |rect|. - const gfx::Size view_size = rect.IsEmpty() ? view->GetViewBounds().size() : - rect.size(); + const gfx::Size view_size = + rect.IsEmpty() ? view->GetViewBounds().size() : rect.size(); // By default, the requested bitmap size is the view size in screen // coordinates. However, if there's more pixel detail available on the // current system, increase the requested bitmap size to capture it all. gfx::Size bitmap_size = view_size; const gfx::NativeView native_view = view->GetNativeView(); - const float scale = - display::Screen::GetScreen()->GetDisplayNearestView(native_view) - .device_scale_factor(); + const float scale = display::Screen::GetScreen() + ->GetDisplayNearestView(native_view) + .device_scale_factor(); if (scale > 1.0f) bitmap_size = gfx::ScaleToCeiledSize(view_size, scale); - view->CopyFromSurface(gfx::Rect(rect.origin(), view_size), - bitmap_size, + view->CopyFromSurface(gfx::Rect(rect.origin(), view_size), bitmap_size, base::Bind(&OnCapturePageDone, callback), kBGRA_8888_SkColorType); } @@ -1697,10 +1691,10 @@ void WebContents::OnCursorChange(const content::WebCursor& cursor) { if (cursor.IsCustom()) { Emit("cursor-changed", CursorTypeToString(info), - gfx::Image::CreateFrom1xBitmap(info.custom_image), - info.image_scale_factor, - gfx::Size(info.custom_image.width(), info.custom_image.height()), - info.hotspot); + gfx::Image::CreateFrom1xBitmap(info.custom_image), + info.image_scale_factor, + gfx::Size(info.custom_image.width(), info.custom_image.height()), + info.hotspot); } else { Emit("cursor-changed", CursorTypeToString(info)); } @@ -1788,7 +1782,7 @@ void WebContents::Invalidate() { if (IsOffScreen()) { #if defined(ENABLE_OSR) auto* osr_rwhv = static_cast( - web_contents()->GetRenderWidgetHostView()); + web_contents()->GetRenderWidgetHostView()); if (osr_rwhv) osr_rwhv->Invalidate(); #endif @@ -1799,8 +1793,7 @@ void WebContents::Invalidate() { } } -gfx::Size WebContents::GetSizeForNewRenderView( - content::WebContents* wc) const { +gfx::Size WebContents::GetSizeForNewRenderView(content::WebContents* wc) const { if (IsOffScreen() && wc == web_contents()) { auto relay = NativeWindowRelay::FromWebContents(web_contents()); if (relay) { @@ -1907,8 +1900,8 @@ void WebContents::SetDevToolsWebContents(const WebContents* devtools) { v8::Local WebContents::GetNativeView() const { gfx::NativeView ptr = web_contents()->GetNativeView(); - auto buffer = node::Buffer::Copy( - isolate(), reinterpret_cast(&ptr), sizeof(gfx::NativeView)); + auto buffer = node::Buffer::Copy(isolate(), reinterpret_cast(&ptr), + sizeof(gfx::NativeView)); if (buffer.IsEmpty()) return v8::Null(isolate()); else @@ -1932,8 +1925,7 @@ v8::Local WebContents::Debugger(v8::Isolate* isolate) { void WebContents::GrantOriginAccess(const GURL& url) { content::ChildProcessSecurityPolicy::GetInstance()->GrantOrigin( - web_contents()->GetMainFrame()->GetProcess()->GetID(), - url::Origin(url)); + web_contents()->GetMainFrame()->GetProcess()->GetID(), url::Origin(url)); } // static @@ -1969,8 +1961,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate, .SetMethod("disableDeviceEmulation", &WebContents::DisableDeviceEmulation) .SetMethod("toggleDevTools", &WebContents::ToggleDevTools) .SetMethod("inspectElement", &WebContents::InspectElement) - .SetMethod("setIgnoreMenuShortcuts", - &WebContents::SetIgnoreMenuShortcuts) + .SetMethod("setIgnoreMenuShortcuts", &WebContents::SetIgnoreMenuShortcuts) .SetMethod("setAudioMuted", &WebContents::SetAudioMuted) .SetMethod("isAudioMuted", &WebContents::IsAudioMuted) .SetMethod("undo", &WebContents::Undo) @@ -2060,27 +2051,30 @@ void WebContents::OnRendererMessageSync(content::RenderFrameHost* frame_host, // static mate::Handle WebContents::CreateFrom( - v8::Isolate* isolate, content::WebContents* web_contents) { + v8::Isolate* isolate, + content::WebContents* web_contents) { // We have an existing WebContents object in JS. auto existing = TrackableObject::FromWrappedClass(isolate, web_contents); if (existing) return mate::CreateHandle(isolate, static_cast(existing)); // Otherwise create a new WebContents wrapper object. - return mate::CreateHandle(isolate, new WebContents(isolate, web_contents, - REMOTE)); + return mate::CreateHandle(isolate, + new WebContents(isolate, web_contents, REMOTE)); } mate::Handle WebContents::CreateFrom( - v8::Isolate* isolate, content::WebContents* web_contents, Type type) { + v8::Isolate* isolate, + content::WebContents* web_contents, + Type type) { // Otherwise create a new WebContents wrapper object. - return mate::CreateHandle(isolate, new WebContents(isolate, web_contents, - type)); + return mate::CreateHandle(isolate, + new WebContents(isolate, web_contents, type)); } // static -mate::Handle WebContents::Create( - v8::Isolate* isolate, const mate::Dictionary& options) { +mate::Handle WebContents::Create(v8::Isolate* isolate, + const mate::Dictionary& options) { return mate::CreateHandle(isolate, new WebContents(isolate, options)); } @@ -2092,8 +2086,10 @@ namespace { using atom::api::WebContents; -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary dict(isolate, exports); dict.Set("WebContents", WebContents::GetConstructor(isolate)->GetFunction()); diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 9c0155c74e1..2049ae8eea4 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -38,7 +38,7 @@ class ResourceRequestBody; namespace mate { class Arguments; class Dictionary; -} +} // namespace mate namespace atom { @@ -82,13 +82,16 @@ class WebContents : public mate::TrackableObject, // Create from an existing WebContents. static mate::Handle CreateFrom( - v8::Isolate* isolate, content::WebContents* web_contents); + v8::Isolate* isolate, + content::WebContents* web_contents); static mate::Handle CreateFrom( - v8::Isolate* isolate, content::WebContents* web_contents, Type type); + v8::Isolate* isolate, + content::WebContents* web_contents, + Type type); // Create a new WebContents. - static mate::Handle Create( - v8::Isolate* isolate, const mate::Dictionary& options); + static mate::Handle Create(v8::Isolate* isolate, + const mate::Dictionary& options); static void BuildPrototype(v8::Isolate* isolate, v8::Local prototype); @@ -133,8 +136,7 @@ class WebContents : public mate::TrackableObject, void DisableDeviceEmulation(); void InspectElement(int x, int y); void InspectServiceWorker(); - void HasServiceWorker( - const base::Callback&); + void HasServiceWorker(const base::Callback&); void UnregisterServiceWorker(const base::Callback&); void SetIgnoreMenuShortcuts(bool ignore); void SetAudioMuted(bool muted); @@ -221,13 +223,12 @@ class WebContents : public mate::TrackableObject, bool allowed); // Create window with the given disposition. - void OnCreateWindow( - const GURL& target_url, - const content::Referrer& referrer, - const std::string& frame_name, - WindowOpenDisposition disposition, - const std::vector& features, - const scoped_refptr& body); + void OnCreateWindow(const GURL& target_url, + const content::Referrer& referrer, + const std::string& frame_name, + WindowOpenDisposition disposition, + const std::vector& features, + const scoped_refptr& body); // Returns the web preferences of current WebContents. v8::Local GetWebPreferences(v8::Isolate* isolate); @@ -264,7 +265,7 @@ class WebContents : public mate::TrackableObject, ~WebContents(); void InitWithSessionAndOptions(v8::Isolate* isolate, - content::WebContents *web_contents, + content::WebContents* web_contents, mate::Handle session, const mate::Dictionary& options); @@ -274,14 +275,12 @@ class WebContents : public mate::TrackableObject, const base::string16& message, int32_t line_no, const base::string16& source_id) override; - void WebContentsCreated( - content::WebContents* source_contents, - int opener_render_process_id, - int opener_render_frame_id, - const std::string& frame_name, - const GURL& target_url, - content::WebContents* new_contents) - override; + void WebContentsCreated(content::WebContents* source_contents, + int opener_render_process_id, + int opener_render_frame_id, + const std::string& frame_name, + const GURL& target_url, + content::WebContents* new_contents) override; void AddNewContents(content::WebContents* source, content::WebContents* new_contents, WindowOpenDisposition disposition, @@ -321,18 +320,16 @@ class WebContents : public mate::TrackableObject, const gfx::Rect& selection_rect, int active_match_ordinal, bool final_update) override; - bool CheckMediaAccessPermission( - content::WebContents* web_contents, - const GURL& security_origin, - content::MediaStreamType type) override; + bool CheckMediaAccessPermission(content::WebContents* web_contents, + const GURL& security_origin, + content::MediaStreamType type) override; void RequestMediaAccessPermission( content::WebContents* web_contents, const content::MediaStreamRequest& request, const content::MediaResponseCallback& callback) override; - void RequestToLockMouse( - content::WebContents* web_contents, - bool user_gesture, - bool last_unlocked_by_target) override; + void RequestToLockMouse(content::WebContents* web_contents, + bool user_gesture, + bool last_unlocked_by_target) override; std::unique_ptr RunBluetoothChooser( content::RenderFrameHost* frame, const content::BluetoothChooser::EventHandler& handler) override; @@ -396,9 +393,7 @@ class WebContents : public mate::TrackableObject, struct FrameDispatchHelper; AtomBrowserContext* GetBrowserContext() const; - uint32_t GetNextRequestId() { - return ++request_id_; - } + uint32_t GetNextRequestId() { return ++request_id_; } #if defined(ENABLE_OSR) OffScreenWebContentsView* GetOffScreenWebContentsView() const; diff --git a/atom/browser/api/atom_api_web_request.cc b/atom/browser/api/atom_api_web_request.cc index ac84ac196b6..eb2b9a72c2e 100644 --- a/atom/browser/api/atom_api_web_request.cc +++ b/atom/browser/api/atom_api_web_request.cc @@ -19,9 +19,10 @@ using content::BrowserThread; namespace mate { -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, URLPattern* out) { std::string pattern; if (!ConvertFromV8(isolate, val, &pattern)) @@ -39,7 +40,7 @@ namespace api { namespace { -template +template void CallNetworkDelegateMethod( brightray::URLRequestContextGetter* url_request_context_getter, Method method, @@ -63,22 +64,21 @@ WebRequest::WebRequest(v8::Isolate* isolate, Init(isolate); } -WebRequest::~WebRequest() { -} +WebRequest::~WebRequest() {} -template +template void WebRequest::SetSimpleListener(mate::Arguments* args) { SetListener( &AtomNetworkDelegate::SetSimpleListenerInIO, type, args); } -template +template void WebRequest::SetResponseListener(mate::Arguments* args) { SetListener( &AtomNetworkDelegate::SetResponseListenerInIO, type, args); } -template +template void WebRequest::SetListener(Method method, Event type, mate::Arguments* args) { // { urls }. URLPatterns patterns; @@ -101,8 +101,8 @@ void WebRequest::SetListener(Method method, Event type, mate::Arguments* args) { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&CallNetworkDelegateMethod, - base::RetainedRef(url_request_context_getter), - method, type, std::move(patterns), std::move(listener))); + base::RetainedRef(url_request_context_getter), method, type, + std::move(patterns), std::move(listener))); } // static @@ -117,30 +117,28 @@ void WebRequest::BuildPrototype(v8::Isolate* isolate, v8::Local prototype) { prototype->SetClassName(mate::StringToV8(isolate, "WebRequest")); mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) - .SetMethod("onBeforeRequest", - &WebRequest::SetResponseListener< - AtomNetworkDelegate::kOnBeforeRequest>) + .SetMethod("onBeforeRequest", &WebRequest::SetResponseListener< + AtomNetworkDelegate::kOnBeforeRequest>) .SetMethod("onBeforeSendHeaders", &WebRequest::SetResponseListener< - AtomNetworkDelegate::kOnBeforeSendHeaders>) + AtomNetworkDelegate::kOnBeforeSendHeaders>) .SetMethod("onHeadersReceived", &WebRequest::SetResponseListener< - AtomNetworkDelegate::kOnHeadersReceived>) - .SetMethod("onSendHeaders", - &WebRequest::SetSimpleListener< - AtomNetworkDelegate::kOnSendHeaders>) + AtomNetworkDelegate::kOnHeadersReceived>) + .SetMethod( + "onSendHeaders", + &WebRequest::SetSimpleListener) .SetMethod("onBeforeRedirect", &WebRequest::SetSimpleListener< - AtomNetworkDelegate::kOnBeforeRedirect>) + AtomNetworkDelegate::kOnBeforeRedirect>) .SetMethod("onResponseStarted", &WebRequest::SetSimpleListener< - AtomNetworkDelegate::kOnResponseStarted>) - .SetMethod("onCompleted", - &WebRequest::SetSimpleListener< - AtomNetworkDelegate::kOnCompleted>) - .SetMethod("onErrorOccurred", - &WebRequest::SetSimpleListener< - AtomNetworkDelegate::kOnErrorOccurred>); + AtomNetworkDelegate::kOnResponseStarted>) + .SetMethod( + "onCompleted", + &WebRequest::SetSimpleListener) + .SetMethod("onErrorOccurred", &WebRequest::SetSimpleListener< + AtomNetworkDelegate::kOnErrorOccurred>); } } // namespace api diff --git a/atom/browser/api/atom_api_web_request.h b/atom/browser/api/atom_api_web_request.h index b05a4e11b98..87fa0881587 100644 --- a/atom/browser/api/atom_api_web_request.h +++ b/atom/browser/api/atom_api_web_request.h @@ -29,11 +29,11 @@ class WebRequest : public mate::TrackableObject { ~WebRequest() override; // C++ can not distinguish overloaded member function. - template + template void SetSimpleListener(mate::Arguments* args); - template + template void SetResponseListener(mate::Arguments* args); - template + template void SetListener(Method method, Event type, mate::Arguments* args); private: diff --git a/atom/browser/api/atom_api_web_view_manager.cc b/atom/browser/api/atom_api_web_view_manager.cc index 347bcc2336b..74eb7ce1793 100644 --- a/atom/browser/api/atom_api_web_view_manager.cc +++ b/atom/browser/api/atom_api_web_view_manager.cc @@ -43,8 +43,10 @@ void RemoveGuest(content::WebContents* embedder, int guest_instance_id) { manager->RemoveGuest(guest_instance_id); } -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { mate::Dictionary dict(context->GetIsolate(), exports); dict.SetMethod("addGuest", &AddGuest); dict.SetMethod("removeGuest", &RemoveGuest); diff --git a/atom/browser/api/event.cc b/atom/browser/api/event.cc index 1ee0d57e360..d5e390f0598 100644 --- a/atom/browser/api/event.cc +++ b/atom/browser/api/event.cc @@ -12,14 +12,11 @@ namespace mate { -Event::Event(v8::Isolate* isolate) - : sender_(nullptr), - message_(nullptr) { +Event::Event(v8::Isolate* isolate) : sender_(nullptr), message_(nullptr) { Init(isolate); } -Event::~Event() { -} +Event::~Event() {} void Event::SetSenderAndMessage(content::RenderFrameHost* sender, IPC::Message* message) { @@ -52,8 +49,7 @@ void Event::FrameDeleted(content::RenderFrameHost* rfh) { } void Event::PreventDefault(v8::Isolate* isolate) { - GetWrapper()->Set(StringToV8(isolate, "defaultPrevented"), - v8::True(isolate)); + GetWrapper()->Set(StringToV8(isolate, "defaultPrevented"), v8::True(isolate)); } bool Event::SendReply(const base::string16& json) { @@ -73,8 +69,8 @@ Handle Event::Create(v8::Isolate* isolate) { } // static -void Event::BuildPrototype( - v8::Isolate* isolate, v8::Local prototype) { +void Event::BuildPrototype(v8::Isolate* isolate, + v8::Local prototype) { prototype->SetClassName(mate::StringToV8(isolate, "Event")); mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) .SetMethod("preventDefault", &Event::PreventDefault) diff --git a/atom/browser/api/event.h b/atom/browser/api/event.h index 05ad7daff8a..10b14c190ab 100644 --- a/atom/browser/api/event.h +++ b/atom/browser/api/event.h @@ -15,8 +15,7 @@ class Message; namespace mate { -class Event : public Wrappable, - public content::WebContentsObserver { +class Event : public Wrappable, public content::WebContentsObserver { public: static Handle Create(v8::Isolate* isolate); diff --git a/atom/browser/api/event_emitter.cc b/atom/browser/api/event_emitter.cc index 91769cbb947..c1c17a55d9a 100644 --- a/atom/browser/api/event_emitter.cc +++ b/atom/browser/api/event_emitter.cc @@ -26,13 +26,14 @@ void PreventDefault(mate::Arguments* args) { // Create a pure JavaScript Event object. v8::Local CreateEventObject(v8::Isolate* isolate) { if (event_template.IsEmpty()) { - event_template.Reset(isolate, ObjectTemplateBuilder(isolate) - .SetMethod("preventDefault", &PreventDefault) - .Build()); + event_template.Reset(isolate, + ObjectTemplateBuilder(isolate) + .SetMethod("preventDefault", &PreventDefault) + .Build()); } - return v8::Local::New( - isolate, event_template)->NewInstance(); + return v8::Local::New(isolate, event_template) + ->NewInstance(); } } // namespace @@ -57,10 +58,9 @@ v8::Local CreateJSEvent(v8::Isolate* isolate, return event; } -v8::Local CreateCustomEvent( - v8::Isolate* isolate, - v8::Local object, - v8::Local custom_event) { +v8::Local CreateCustomEvent(v8::Isolate* isolate, + v8::Local object, + v8::Local custom_event) { v8::Local event = CreateEventObject(isolate); (void)event->SetPrototype(custom_event->CreationContext(), custom_event); mate::Dictionary(isolate, event).Set("sender", object); diff --git a/atom/browser/api/event_emitter.h b/atom/browser/api/event_emitter.h index 8145113084a..5e4ca3b4ffc 100644 --- a/atom/browser/api/event_emitter.h +++ b/atom/browser/api/event_emitter.h @@ -26,16 +26,15 @@ v8::Local CreateJSEvent(v8::Isolate* isolate, v8::Local object, content::RenderFrameHost* sender, IPC::Message* message); -v8::Local CreateCustomEvent( - v8::Isolate* isolate, - v8::Local object, - v8::Local event); +v8::Local CreateCustomEvent(v8::Isolate* isolate, + v8::Local object, + v8::Local event); v8::Local CreateEventFromFlags(v8::Isolate* isolate, int flags); } // namespace internal // Provide helperers to emit event in JavaScript. -template +template class EventEmitter : public Wrappable { public: typedef std::vector> ValueArray; @@ -48,27 +47,26 @@ class EventEmitter : public Wrappable { } // this.emit(name, event, args...); - template + template bool EmitCustomEvent(const base::StringPiece& name, v8::Local event, const Args&... args) { return EmitWithEvent( - name, - internal::CreateCustomEvent(isolate(), GetWrapper(), event), args...); + name, internal::CreateCustomEvent(isolate(), GetWrapper(), event), + args...); } // this.emit(name, new Event(flags), args...); - template + template bool EmitWithFlags(const base::StringPiece& name, int flags, const Args&... args) { return EmitCustomEvent( - name, - internal::CreateEventFromFlags(isolate(), flags), args...); + name, internal::CreateEventFromFlags(isolate(), flags), args...); } // this.emit(name, new Event(), args...); - template + template bool Emit(const base::StringPiece& name, const Args&... args) { return EmitWithSender(name, nullptr, nullptr, args...); } @@ -85,8 +83,8 @@ class EventEmitter : public Wrappable { if (wrapper.IsEmpty()) { return false; } - v8::Local event = internal::CreateJSEvent( - isolate(), wrapper, sender, message); + v8::Local event = + internal::CreateJSEvent(isolate(), wrapper, sender, message); return EmitWithEvent(name, event, args...); } @@ -95,15 +93,15 @@ class EventEmitter : public Wrappable { private: // this.emit(name, event, args...); - template + template bool EmitWithEvent(const base::StringPiece& name, v8::Local event, const Args&... args) { v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); EmitEvent(isolate(), GetWrapper(), name, event, args...); - return event->Get( - StringToV8(isolate(), "defaultPrevented"))->BooleanValue(); + return event->Get(StringToV8(isolate(), "defaultPrevented")) + ->BooleanValue(); } DISALLOW_COPY_AND_ASSIGN(EventEmitter); diff --git a/atom/browser/api/frame_subscriber.cc b/atom/browser/api/frame_subscriber.cc index 76ed89b8f1a..7248b29dff2 100644 --- a/atom/browser/api/frame_subscriber.cc +++ b/atom/browser/api/frame_subscriber.cc @@ -25,8 +25,7 @@ FrameSubscriber::FrameSubscriber(v8::Isolate* isolate, callback_(callback), only_dirty_(only_dirty), source_id_for_copy_request_(base::UnguessableToken::Create()), - weak_factory_(this) { -} + weak_factory_(this) {} bool FrameSubscriber::ShouldCaptureFrame( const gfx::Rect& dirty_rect, @@ -46,19 +45,18 @@ bool FrameSubscriber::ShouldCaptureFrame( gfx::Size view_size = rect.size(); gfx::Size bitmap_size = view_size; gfx::NativeView native_view = view_->GetNativeView(); - const float scale = - display::Screen::GetScreen()->GetDisplayNearestView(native_view) - .device_scale_factor(); + const float scale = display::Screen::GetScreen() + ->GetDisplayNearestView(native_view) + .device_scale_factor(); if (scale > 1.0f) bitmap_size = gfx::ScaleToCeiledSize(view_size, scale); rect = gfx::Rect(rect.origin(), bitmap_size); view_->CopyFromSurface( - rect, - rect.size(), - base::Bind(&FrameSubscriber::OnFrameDelivered, - weak_factory_.GetWeakPtr(), callback_, rect), + rect, rect.size(), + base::Bind(&FrameSubscriber::OnFrameDelivered, weak_factory_.GetWeakPtr(), + callback_, rect), kBGRA_8888_SkColorType); return false; diff --git a/atom/browser/api/save_page_handler.cc b/atom/browser/api/save_page_handler.cc index e07ec3ac0ab..07505edbd20 100644 --- a/atom/browser/api/save_page_handler.cc +++ b/atom/browser/api/save_page_handler.cc @@ -17,12 +17,9 @@ namespace api { SavePageHandler::SavePageHandler(content::WebContents* web_contents, const SavePageCallback& callback) - : web_contents_(web_contents), - callback_(callback) { -} + : web_contents_(web_contents), callback_(callback) {} -SavePageHandler::~SavePageHandler() { -} +SavePageHandler::~SavePageHandler() {} void SavePageHandler::OnDownloadCreated(content::DownloadManager* manager, content::DownloadItem* item) { @@ -41,9 +38,8 @@ bool SavePageHandler::Handle(const base::FilePath& full_path, base::FilePath saved_main_directory_path = full_path.DirName().Append( full_path.RemoveExtension().BaseName().value() + FILE_PATH_LITERAL("_files")); - bool result = web_contents_->SavePage(full_path, - saved_main_directory_path, - save_type); + bool result = + web_contents_->SavePage(full_path, saved_main_directory_path, save_type); download_manager->RemoveObserver(this); // If initialization fails which means fail to create |DownloadItem|, we need // to delete the |SavePageHandler| instance to avoid memory-leak. @@ -60,8 +56,8 @@ void SavePageHandler::OnDownloadUpdated(content::DownloadItem* item) { if (item->GetState() == content::DownloadItem::COMPLETE) { callback_.Run(v8::Null(isolate)); } else { - v8::Local error_message = v8::String::NewFromUtf8( - isolate, "Fail to save page"); + v8::Local error_message = + v8::String::NewFromUtf8(isolate, "Fail to save page"); callback_.Run(v8::Exception::Error(error_message)); } Destroy(item); diff --git a/atom/browser/api/trackable_object.cc b/atom/browser/api/trackable_object.cc index 1563998a99e..4b75d0ac094 100644 --- a/atom/browser/api/trackable_object.cc +++ b/atom/browser/api/trackable_object.cc @@ -34,8 +34,7 @@ TrackableObjectBase::TrackableObjectBase() GetDestroyClosure()); } -TrackableObjectBase::~TrackableObjectBase() { -} +TrackableObjectBase::~TrackableObjectBase() {} base::OnceClosure TrackableObjectBase::GetDestroyClosure() { return base::BindOnce(&TrackableObjectBase::Destroy, @@ -48,7 +47,7 @@ void TrackableObjectBase::Destroy() { void TrackableObjectBase::AttachAsUserData(base::SupportsUserData* wrapped) { wrapped->SetUserData(kTrackedObjectKey, - std::make_unique(weak_map_id_)); + std::make_unique(weak_map_id_)); } // static diff --git a/atom/browser/api/trackable_object.h b/atom/browser/api/trackable_object.h index cbe5e221fe7..2851902a3dd 100644 --- a/atom/browser/api/trackable_object.h +++ b/atom/browser/api/trackable_object.h @@ -51,7 +51,7 @@ class TrackableObjectBase { // All instances of TrackableObject will be kept in a weak map and can be got // from its ID. -template +template class TrackableObject : public TrackableObjectBase, public mate::EventEmitter { public: @@ -107,13 +107,9 @@ class TrackableObject : public TrackableObjectBase, } protected: - TrackableObject() { - weak_map_id_ = ++next_id_; - } + TrackableObject() { weak_map_id_ = ++next_id_; } - ~TrackableObject() override { - RemoveFromWeakMap(); - } + ~TrackableObject() override { RemoveFromWeakMap(); } void InitWith(v8::Isolate* isolate, v8::Local wrapper) override { WrappableBase::InitWith(isolate, wrapper); @@ -130,10 +126,10 @@ class TrackableObject : public TrackableObjectBase, DISALLOW_COPY_AND_ASSIGN(TrackableObject); }; -template +template int32_t TrackableObject::next_id_ = 0; -template +template atom::KeyWeakMap* TrackableObject::weak_map_ = nullptr; } // namespace mate diff --git a/atom/browser/atom_blob_reader.cc b/atom/browser/atom_blob_reader.cc index 5dc73b96942..4b9952d9001 100644 --- a/atom/browser/atom_blob_reader.cc +++ b/atom/browser/atom_blob_reader.cc @@ -25,19 +25,19 @@ void FreeNodeBufferData(char* data, void* hint) { delete[] data; } -void RunCallbackInUI( - const AtomBlobReader::CompletionCallback& callback, - char* blob_data, - int size) { +void RunCallbackInUI(const AtomBlobReader::CompletionCallback& callback, + char* blob_data, + int size) { DCHECK_CURRENTLY_ON(BrowserThread::UI); v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::Locker locker(isolate); v8::HandleScope handle_scope(isolate); if (blob_data) { - v8::Local buffer = node::Buffer::New(isolate, - blob_data, static_cast(size), &FreeNodeBufferData, nullptr) - .ToLocalChecked(); + v8::Local buffer = + node::Buffer::New(isolate, blob_data, static_cast(size), + &FreeNodeBufferData, nullptr) + .ToLocalChecked(); callback.Run(buffer); } else { callback.Run(v8::Null(isolate)); @@ -46,33 +46,26 @@ void RunCallbackInUI( } // namespace -AtomBlobReader::AtomBlobReader( - content::ChromeBlobStorageContext* blob_context, - storage::FileSystemContext* file_system_context) - : blob_context_(blob_context), - file_system_context_(file_system_context) { -} +AtomBlobReader::AtomBlobReader(content::ChromeBlobStorageContext* blob_context, + storage::FileSystemContext* file_system_context) + : blob_context_(blob_context), file_system_context_(file_system_context) {} -AtomBlobReader::~AtomBlobReader() { -} +AtomBlobReader::~AtomBlobReader() {} void AtomBlobReader::StartReading( const std::string& uuid, const AtomBlobReader::CompletionCallback& completion_callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); - auto blob_data_handle = - blob_context_->context()->GetBlobDataFromUUID(uuid); - auto callback = base::Bind(&RunCallbackInUI, - completion_callback); + auto blob_data_handle = blob_context_->context()->GetBlobDataFromUUID(uuid); + auto callback = base::Bind(&RunCallbackInUI, completion_callback); if (!blob_data_handle) { BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - base::Bind(callback, nullptr, 0)); + base::Bind(callback, nullptr, 0)); return; } - auto blob_reader = blob_data_handle->CreateReader( - file_system_context_.get()); + auto blob_reader = blob_data_handle->CreateReader(file_system_context_.get()); BlobReadHelper* blob_read_helper = new BlobReadHelper(std::move(blob_reader), callback); blob_read_helper->Read(); @@ -81,12 +74,9 @@ void AtomBlobReader::StartReading( AtomBlobReader::BlobReadHelper::BlobReadHelper( std::unique_ptr blob_reader, const BlobReadHelper::CompletionCallback& callback) - : blob_reader_(std::move(blob_reader)), - completion_callback_(callback) { -} + : blob_reader_(std::move(blob_reader)), completion_callback_(callback) {} -AtomBlobReader::BlobReadHelper::~BlobReadHelper() { -} +AtomBlobReader::BlobReadHelper::~BlobReadHelper() {} void AtomBlobReader::BlobReadHelper::Read() { DCHECK_CURRENTLY_ON(BrowserThread::IO); @@ -110,14 +100,11 @@ void AtomBlobReader::BlobReadHelper::DidCalculateSize(int result) { int bytes_read = 0; scoped_refptr blob_data = new net::IOBuffer(static_cast(total_size)); - auto callback = base::Bind(&AtomBlobReader::BlobReadHelper::DidReadBlobData, - base::Unretained(this), - base::RetainedRef(blob_data)); - storage::BlobReader::Status read_status = blob_reader_->Read( - blob_data.get(), - total_size, - &bytes_read, - callback); + auto callback = + base::Bind(&AtomBlobReader::BlobReadHelper::DidReadBlobData, + base::Unretained(this), base::RetainedRef(blob_data)); + storage::BlobReader::Status read_status = + blob_reader_->Read(blob_data.get(), total_size, &bytes_read, callback); if (read_status != storage::BlobReader::Status::IO_PENDING) callback.Run(bytes_read); } @@ -130,7 +117,7 @@ void AtomBlobReader::BlobReadHelper::DidReadBlobData( char* data = new char[size]; memcpy(data, blob_data->data(), size); BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - base::Bind(completion_callback_, data, size)); + base::Bind(completion_callback_, data, size)); delete this; } diff --git a/atom/browser/atom_blob_reader.h b/atom/browser/atom_blob_reader.h index 41d9cf9194d..818d4be181f 100644 --- a/atom/browser/atom_blob_reader.h +++ b/atom/browser/atom_blob_reader.h @@ -21,13 +21,13 @@ namespace storage { class BlobDataHandle; class BlobReader; class FileSystemContext; -} +} // namespace storage namespace v8 { template class Local; class Value; -} +} // namespace v8 namespace atom { @@ -41,9 +41,8 @@ class AtomBlobReader { storage::FileSystemContext* file_system_context); ~AtomBlobReader(); - void StartReading( - const std::string& uuid, - const AtomBlobReader::CompletionCallback& callback); + void StartReading(const std::string& uuid, + const AtomBlobReader::CompletionCallback& callback); private: // A self-destroyed helper class to read the blob data. diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index 386cd34cf10..6d193c3cffc 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -90,8 +90,7 @@ void AtomBrowserClient::SetCustomServiceWorkerSchemes( AtomBrowserClient::AtomBrowserClient() : delegate_(nullptr) {} -AtomBrowserClient::~AtomBrowserClient() { -} +AtomBrowserClient::~AtomBrowserClient() {} content::WebContents* AtomBrowserClient::GetWebContentsFromProcessID( int process_id) { @@ -138,7 +137,8 @@ bool AtomBrowserClient::ShouldCreateNewSiteInstance( } void AtomBrowserClient::AddProcessPreferences( - int process_id, AtomBrowserClient::ProcessPreferences prefs) { + int process_id, + AtomBrowserClient::ProcessPreferences prefs) { process_preferences_[process_id] = prefs; } @@ -178,8 +178,8 @@ void AtomBrowserClient::RenderProcessWillLaunch( new WidevineCdmMessageFilter(process_id, host->GetBrowserContext())); ProcessPreferences prefs; - auto* web_preferences = WebContentsPreferences::From( - GetWebContentsFromProcessID(process_id)); + auto* web_preferences = + WebContentsPreferences::From(GetWebContentsFromProcessID(process_id)); if (web_preferences) { prefs.sandbox = web_preferences->IsEnabled("sandbox"); prefs.native_window_open = web_preferences->IsEnabled("nativeWindowOpen"); @@ -191,12 +191,12 @@ void AtomBrowserClient::RenderProcessWillLaunch( } content::SpeechRecognitionManagerDelegate* - AtomBrowserClient::CreateSpeechRecognitionManagerDelegate() { +AtomBrowserClient::CreateSpeechRecognitionManagerDelegate() { return new AtomSpeechRecognitionManagerDelegate; } -void AtomBrowserClient::OverrideWebkitPrefs( - content::RenderViewHost* host, content::WebPreferences* prefs) { +void AtomBrowserClient::OverrideWebkitPrefs(content::RenderViewHost* host, + content::WebPreferences* prefs) { prefs->javascript_enabled = true; prefs->web_security_enabled = true; prefs->plugins_enabled = true; @@ -295,14 +295,12 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches( return; // Copy following switches to child process. - static const char* const kCommonSwitchNames[] = { - switches::kStandardSchemes, - switches::kEnableSandbox, - switches::kSecureSchemes - }; - command_line->CopySwitchesFrom( - *base::CommandLine::ForCurrentProcess(), - kCommonSwitchNames, arraysize(kCommonSwitchNames)); + static const char* const kCommonSwitchNames[] = {switches::kStandardSchemes, + switches::kEnableSandbox, + switches::kSecureSchemes}; + command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(), + kCommonSwitchNames, + arraysize(kCommonSwitchNames)); // The registered service worker schemes. if (!g_custom_service_worker_schemes.empty()) @@ -331,15 +329,13 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches( SessionPreferences::AppendExtraCommandLineSwitches( web_contents->GetBrowserContext(), command_line); - auto context_id = atom::api::WebContents::GetIDForContents( - web_contents); + auto context_id = atom::api::WebContents::GetIDForContents(web_contents); command_line->AppendSwitchASCII(switches::kContextId, - base::IntToString(context_id)); + base::IntToString(context_id)); } } -void AtomBrowserClient::DidCreatePpapiPlugin( - content::BrowserPpapiHost* host) { +void AtomBrowserClient::DidCreatePpapiPlugin(content::BrowserPpapiHost* host) { host->GetPpapiHost()->AddHostFactoryFilter( base::WrapUnique(new chrome::ChromeBrowserPepperHostFactory(host))); } @@ -363,7 +359,7 @@ std::string AtomBrowserClient::GetGeolocationApiKey() { } content::QuotaPermissionContext* - AtomBrowserClient::CreateQuotaPermissionContext() { +AtomBrowserClient::CreateQuotaPermissionContext() { return new AtomQuotaPermissionContext; } @@ -379,9 +375,8 @@ void AtomBrowserClient::AllowCertificateError( callback) { if (delegate_) { delegate_->AllowCertificateError( - web_contents, cert_error, ssl_info, request_url, - resource_type, strict_enforcement, - expired_previous_decision, callback); + web_contents, cert_error, ssl_info, request_url, resource_type, + strict_enforcement, expired_previous_decision, callback); } } @@ -455,8 +450,7 @@ void AtomBrowserClient::GetAdditionalAllowedSchemesForFileSystem( std::vector* additional_schemes) { auto schemes_list = api::GetStandardSchemes(); if (!schemes_list.empty()) - additional_schemes->insert(additional_schemes->end(), - schemes_list.begin(), + additional_schemes->insert(additional_schemes->end(), schemes_list.begin(), schemes_list.end()); additional_schemes->push_back(content::kChromeDevToolsScheme); } @@ -466,7 +460,7 @@ void AtomBrowserClient::SiteInstanceDeleting( // We are storing weak_ptr, is it fundamental to maintain the map up-to-date // when an instance is destroyed. for (auto iter = site_per_affinities.begin(); - iter != site_per_affinities.end(); ++iter) { + iter != site_per_affinities.end(); ++iter) { if (iter->second == site_instance) { site_per_affinities.erase(iter); break; diff --git a/atom/browser/atom_browser_client.h b/atom/browser/atom_browser_client.h index 2cd4fe69daa..b2e7ae61144 100644 --- a/atom/browser/atom_browser_client.h +++ b/atom/browser/atom_browser_client.h @@ -17,7 +17,7 @@ namespace content { class QuotaPermissionContext; class ClientCertificateDelegate; -} +} // namespace content namespace net { class SSLCertRequestInfo; @@ -50,7 +50,7 @@ class AtomBrowserClient : public brightray::BrowserClient, // content::ContentBrowserClient: void RenderProcessWillLaunch(content::RenderProcessHost* host) override; content::SpeechRecognitionManagerDelegate* - CreateSpeechRecognitionManagerDelegate() override; + CreateSpeechRecognitionManagerDelegate() override; void OverrideWebkitPrefs(content::RenderViewHost* render_view_host, content::WebPreferences* prefs) override; void OverrideSiteInstanceForNavigation( @@ -84,22 +84,21 @@ class AtomBrowserClient : public brightray::BrowserClient, net::ClientCertIdentityList client_certs, std::unique_ptr delegate) override; void ResourceDispatcherHostCreated() override; - bool CanCreateWindow( - content::RenderFrameHost* opener, - const GURL& opener_url, - const GURL& opener_top_level_frame_url, - const GURL& source_origin, - content::mojom::WindowContainerType container_type, - const GURL& target_url, - const content::Referrer& referrer, - const std::string& frame_name, - WindowOpenDisposition disposition, - const blink::mojom::WindowFeatures& features, - const std::vector& additional_features, - const scoped_refptr& body, - bool user_gesture, - bool opener_suppressed, - bool* no_javascript_access) override; + bool CanCreateWindow(content::RenderFrameHost* opener, + const GURL& opener_url, + const GURL& opener_top_level_frame_url, + const GURL& source_origin, + content::mojom::WindowContainerType container_type, + const GURL& target_url, + const content::Referrer& referrer, + const std::string& frame_name, + WindowOpenDisposition disposition, + const blink::mojom::WindowFeatures& features, + const std::vector& additional_features, + const scoped_refptr& body, + bool user_gesture, + bool opener_suppressed, + bool* no_javascript_access) override; void GetAdditionalAllowedSchemesForFileSystem( std::vector* schemes) override; void SiteInstanceDeleting(content::SiteInstance* site_instance) override; diff --git a/atom/browser/atom_browser_context.cc b/atom/browser/atom_browser_context.cc index ede18c88fe3..78f3d1a793c 100644 --- a/atom/browser/atom_browser_context.cc +++ b/atom/browser/atom_browser_context.cc @@ -77,14 +77,12 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition, std::string name = RemoveWhitespace(browser->GetName()); std::string user_agent; if (name == ATOM_PRODUCT_NAME) { - user_agent = "Chrome/" CHROME_VERSION_STRING " " - ATOM_PRODUCT_NAME "/" ATOM_VERSION_STRING; + user_agent = "Chrome/" CHROME_VERSION_STRING " " ATOM_PRODUCT_NAME + "/" ATOM_VERSION_STRING; } else { user_agent = base::StringPrintf( "%s/%s Chrome/%s " ATOM_PRODUCT_NAME "/" ATOM_VERSION_STRING, - name.c_str(), - browser->GetVersion().c_str(), - CHROME_VERSION_STRING); + name.c_str(), browser->GetVersion().c_str(), CHROME_VERSION_STRING); } user_agent_ = content::BuildUserAgentFromProduct(user_agent); @@ -96,8 +94,7 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition, InitPrefs(); } -AtomBrowserContext::~AtomBrowserContext() { -} +AtomBrowserContext::~AtomBrowserContext() {} void AtomBrowserContext::SetUserAgent(const std::string& user_agent) { user_agent_ = user_agent; @@ -156,8 +153,7 @@ AtomBrowserContext::CreateURLRequestJobFactory( auto host_resolver = url_request_context_getter()->GetURLRequestContext()->host_resolver(); job_factory->SetProtocolHandler( - url::kFtpScheme, - net::FtpProtocolHandler::Create(host_resolver)); + url::kFtpScheme, net::FtpProtocolHandler::Create(host_resolver)); return std::move(job_factory); } @@ -202,8 +198,8 @@ std::unique_ptr AtomBrowserContext::CreateCertVerifier( std::vector AtomBrowserContext::GetCookieableSchemes() { auto default_schemes = brightray::BrowserContext::GetCookieableSchemes(); const auto& standard_schemes = atom::api::GetStandardSchemes(); - default_schemes.insert(default_schemes.end(), - standard_schemes.begin(), standard_schemes.end()); + default_schemes.insert(default_schemes.end(), standard_schemes.begin(), + standard_schemes.end()); return default_schemes; } @@ -230,17 +226,17 @@ AtomBlobReader* AtomBrowserContext::GetBlobReader() { content::ChromeBlobStorageContext* blob_context = content::ChromeBlobStorageContext::GetFor(this); storage::FileSystemContext* file_system_context = - content::BrowserContext::GetStoragePartition( - this, nullptr)->GetFileSystemContext(); - blob_reader_.reset(new AtomBlobReader(blob_context, - file_system_context)); + content::BrowserContext::GetStoragePartition(this, nullptr) + ->GetFileSystemContext(); + blob_reader_.reset(new AtomBlobReader(blob_context, file_system_context)); } return blob_reader_.get(); } // static scoped_refptr AtomBrowserContext::From( - const std::string& partition, bool in_memory, + const std::string& partition, + bool in_memory, const base::DictionaryValue& options) { auto browser_context = brightray::BrowserContext::Get(partition, in_memory); if (browser_context) diff --git a/atom/browser/atom_browser_context.h b/atom/browser/atom_browser_context.h index 8ac8d167f13..f825413a96c 100644 --- a/atom/browser/atom_browser_context.h +++ b/atom/browser/atom_browser_context.h @@ -26,7 +26,8 @@ class AtomBrowserContext : public brightray::BrowserContext { // |in_memory|. The |options| will be passed to constructor when there is no // existing BrowserContext. static scoped_refptr From( - const std::string& partition, bool in_memory, + const std::string& partition, + bool in_memory, const base::DictionaryValue& options = base::DictionaryValue()); void SetUserAgent(const std::string& user_agent); @@ -67,7 +68,8 @@ class AtomBrowserContext : public brightray::BrowserContext { } protected: - AtomBrowserContext(const std::string& partition, bool in_memory, + AtomBrowserContext(const std::string& partition, + bool in_memory, const base::DictionaryValue& options); ~AtomBrowserContext() override; diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index a0bdcb1da85..0afb4348bc2 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -56,7 +56,7 @@ class AtomGeolocationDelegate : public device::GeolocationDelegate { DISALLOW_COPY_AND_ASSIGN(AtomGeolocationDelegate); }; -template +template void Erase(T* container, typename T::iterator iter) { container->erase(iter); } @@ -76,8 +76,8 @@ AtomBrowserMainParts::AtomBrowserMainParts() DCHECK(!self_) << "Cannot have two AtomBrowserMainParts"; self_ = this; // Register extension scheme as web safe scheme. - content::ChildProcessSecurityPolicy::GetInstance()-> - RegisterWebSafeScheme("chrome-extension"); + content::ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( + "chrome-extension"); } AtomBrowserMainParts::~AtomBrowserMainParts() { @@ -85,10 +85,11 @@ AtomBrowserMainParts::~AtomBrowserMainParts() { // Leak the JavascriptEnvironment on exit. // This is to work around the bug that V8 would be waiting for background // tasks to finish on exit, while somehow it waits forever in Electron, more - // about this can be found at https://github.com/electron/electron/issues/4767. - // On the other handle there is actually no need to gracefully shutdown V8 - // on exit in the main process, we already ensured all necessary resources get - // cleaned up, and it would make quitting faster. + // about this can be found at + // https://github.com/electron/electron/issues/4767. On the other handle there + // is actually no need to gracefully shutdown V8 on exit in the main process, + // we already ensured all necessary resources get cleaned up, and it would + // make quitting faster. ignore_result(js_env_.release()); } @@ -163,9 +164,9 @@ int AtomBrowserMainParts::PreCreateThreads() { brightray::BrowserClient::Get()->GetApplicationLocale()); } - #if defined(OS_MACOSX) - ui::InitIdleMonitor(); - #endif +#if defined(OS_MACOSX) + ui::InitIdleMonitor(); +#endif return result; } @@ -183,10 +184,9 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() { #endif // Start idle gc. - gc_timer_.Start( - FROM_HERE, base::TimeDelta::FromMinutes(1), - base::Bind(&v8::Isolate::LowMemoryNotification, - base::Unretained(js_env_->isolate()))); + gc_timer_.Start(FROM_HERE, base::TimeDelta::FromMinutes(1), + base::Bind(&v8::Isolate::LowMemoryNotification, + base::Unretained(js_env_->isolate()))); #if defined(ENABLE_PDF_VIEWER) content::WebUIControllerFactory::RegisterFactory( diff --git a/atom/browser/atom_browser_main_parts_posix.cc b/atom/browser/atom_browser_main_parts_posix.cc index d208ea8b744..d79e60049f4 100644 --- a/atom/browser/atom_browser_main_parts_posix.cc +++ b/atom/browser/atom_browser_main_parts_posix.cc @@ -24,8 +24,7 @@ namespace atom { namespace { // See comment in |PreEarlyInitialization()|, where sigaction is called. -void SIGCHLDHandler(int signal) { -} +void SIGCHLDHandler(int signal) {} // The OSX fork() implementation can crash in the child process before // fork() returns. In that case, the shutdown pipe will still be @@ -121,8 +120,7 @@ void ShutdownDetector::ThreadMain() { size_t bytes_read = 0; do { ssize_t ret = HANDLE_EINTR( - read(shutdown_fd_, - reinterpret_cast(&signal) + bytes_read, + read(shutdown_fd_, reinterpret_cast(&signal) + bytes_read, sizeof(signal) - bytes_read)); if (ret < 0) { NOTREACHED() << "Unexpected error: " << strerror(errno); diff --git a/atom/browser/atom_download_manager_delegate.cc b/atom/browser/atom_download_manager_delegate.cc index 21ceaad5942..008b1e65ac7 100644 --- a/atom/browser/atom_download_manager_delegate.cc +++ b/atom/browser/atom_download_manager_delegate.cc @@ -50,8 +50,7 @@ void CreateDownloadPath( AtomDownloadManagerDelegate::AtomDownloadManagerDelegate( content::DownloadManager* manager) - : download_manager_(manager), - weak_ptr_factory_(this) {} + : download_manager_(manager), weak_ptr_factory_(this) {} AtomDownloadManagerDelegate::~AtomDownloadManagerDelegate() { if (download_manager_) { @@ -67,8 +66,8 @@ void AtomDownloadManagerDelegate::GetItemSavePath(content::DownloadItem* item, v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::Locker locker(isolate); v8::HandleScope handle_scope(isolate); - api::DownloadItem* download = api::DownloadItem::FromWrappedClass(isolate, - item); + api::DownloadItem* download = + api::DownloadItem::FromWrappedClass(isolate, item); if (download) *path = download->GetSavePath(); } @@ -85,8 +84,8 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated( NativeWindow* window = nullptr; content::WebContents* web_contents = item->GetWebContents(); - auto relay = web_contents ? NativeWindowRelay::FromWebContents(web_contents) - : nullptr; + auto relay = + web_contents ? NativeWindowRelay::FromWebContents(web_contents) : nullptr; if (relay) window = relay->window.get(); @@ -111,8 +110,8 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated( v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::Locker locker(isolate); v8::HandleScope handle_scope(isolate); - api::DownloadItem* download_item = api::DownloadItem::FromWrappedClass( - isolate, item); + api::DownloadItem* download_item = + api::DownloadItem::FromWrappedClass(isolate, item); if (download_item) download_item->SetSavePath(path); } @@ -120,12 +119,10 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated( // Running the DownloadTargetCallback with an empty FilePath signals that the // download should be cancelled. // If user cancels the file save dialog, run the callback with empty FilePath. - callback.Run(path, - content::DownloadItem::TARGET_DISPOSITION_PROMPT, + callback.Run(path, content::DownloadItem::TARGET_DISPOSITION_PROMPT, content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, path, - path.empty() ? - content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED : - content::DOWNLOAD_INTERRUPT_REASON_NONE); + path.empty() ? content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED + : content::DOWNLOAD_INTERRUPT_REASON_NONE); } void AtomDownloadManagerDelegate::Shutdown() { @@ -151,22 +148,20 @@ bool AtomDownloadManagerDelegate::DetermineDownloadTarget( base::FilePath save_path; GetItemSavePath(download, &save_path); if (!save_path.empty()) { - callback.Run(save_path, - content::DownloadItem::TARGET_DISPOSITION_OVERWRITE, - content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, - save_path, content::DOWNLOAD_INTERRUPT_REASON_NONE); + callback.Run(save_path, content::DownloadItem::TARGET_DISPOSITION_OVERWRITE, + content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, save_path, + content::DOWNLOAD_INTERRUPT_REASON_NONE); return true; } - AtomBrowserContext* browser_context = static_cast( - download_manager_->GetBrowserContext()); - base::FilePath default_download_path = browser_context->prefs()->GetFilePath( - prefs::kDownloadDefaultDirectory); + AtomBrowserContext* browser_context = + static_cast(download_manager_->GetBrowserContext()); + base::FilePath default_download_path = + browser_context->prefs()->GetFilePath(prefs::kDownloadDefaultDirectory); CreateDownloadPathCallback download_path_callback = base::Bind(&AtomDownloadManagerDelegate::OnDownloadPathGenerated, - weak_ptr_factory_.GetWeakPtr(), - download->GetId(), callback); + weak_ptr_factory_.GetWeakPtr(), download->GetId(), callback); content::BrowserThread::PostTask( content::BrowserThread::FILE, FROM_HERE, diff --git a/atom/browser/atom_javascript_dialog_manager.cc b/atom/browser/atom_javascript_dialog_manager.cc index 70e2b43200e..ea3869ae9e6 100644 --- a/atom/browser/atom_javascript_dialog_manager.cc +++ b/atom/browser/atom_javascript_dialog_manager.cc @@ -57,8 +57,7 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog( auto* web_preferences = WebContentsPreferences::From(web_contents); std::string checkbox; - if (origin_counts_[origin] > 1 && - web_preferences && + if (origin_counts_[origin] > 1 && web_preferences && web_preferences->IsEnabled("safeDialogs") && !web_preferences->dict()->GetString("safeDialogsMessage", &checkbox)) { checkbox = "Prevent this app from creating additional dialogs"; @@ -73,14 +72,11 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog( } atom::ShowMessageBox( - window, - atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, -1, 0, + window, atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, -1, 0, atom::MessageBoxOptions::MESSAGE_BOX_NONE, "", - base::UTF16ToUTF8(message_text), "", checkbox, - false, gfx::ImageSkia(), + base::UTF16ToUTF8(message_text), "", checkbox, false, gfx::ImageSkia(), base::Bind(&AtomJavaScriptDialogManager::OnMessageBoxCallback, - base::Unretained(this), - base::Passed(std::move(callback)), + base::Unretained(this), base::Passed(std::move(callback)), origin)); } @@ -95,8 +91,7 @@ void AtomJavaScriptDialogManager::RunBeforeUnloadDialog( void AtomJavaScriptDialogManager::CancelDialogs( content::WebContents* web_contents, - bool reset_state) { -} + bool reset_state) {} void AtomJavaScriptDialogManager::OnMessageBoxCallback( DialogClosedCallback callback, diff --git a/atom/browser/atom_javascript_dialog_manager.h b/atom/browser/atom_javascript_dialog_manager.h index bbfd94479db..68e6fd150ab 100644 --- a/atom/browser/atom_javascript_dialog_manager.h +++ b/atom/browser/atom_javascript_dialog_manager.h @@ -21,18 +21,16 @@ class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager { explicit AtomJavaScriptDialogManager(api::WebContents* api_web_contents); // content::JavaScriptDialogManager implementations. - void RunJavaScriptDialog( - content::WebContents* web_contents, - const GURL& origin_url, - content::JavaScriptDialogType dialog_type, - const base::string16& message_text, - const base::string16& default_prompt_text, - DialogClosedCallback callback, - bool* did_suppress_message) override; - void RunBeforeUnloadDialog( - content::WebContents* web_contents, - bool is_reload, - DialogClosedCallback callback) override; + void RunJavaScriptDialog(content::WebContents* web_contents, + const GURL& origin_url, + content::JavaScriptDialogType dialog_type, + const base::string16& message_text, + const base::string16& default_prompt_text, + DialogClosedCallback callback, + bool* did_suppress_message) override; + void RunBeforeUnloadDialog(content::WebContents* web_contents, + bool is_reload, + DialogClosedCallback callback) override; void CancelDialogs(content::WebContents* web_contents, bool reset_state) override; diff --git a/atom/browser/atom_permission_manager.cc b/atom/browser/atom_permission_manager.cc index e6d6f58e0e5..4add5e9e085 100644 --- a/atom/browser/atom_permission_manager.cc +++ b/atom/browser/atom_permission_manager.cc @@ -21,8 +21,8 @@ namespace { bool WebContentsDestroyed(int process_id) { content::WebContents* web_contents = - static_cast(AtomBrowserClient::Get())-> - GetWebContentsFromProcessID(process_id); + static_cast(AtomBrowserClient::Get()) + ->GetWebContentsFromProcessID(process_id); if (!web_contents) return true; return web_contents->IsBeingDestroyed(); @@ -54,17 +54,11 @@ class AtomPermissionManager::PendingRequest { --remaining_results_; } - int render_process_id() const { - return render_process_id_; - } + int render_process_id() const { return render_process_id_; } - bool IsComplete() const { - return remaining_results_ == 0; - } + bool IsComplete() const { return remaining_results_ == 0; } - void RunCallback() const { - callback_.Run(results_); - } + void RunCallback() const { callback_.Run(results_); } private: int render_process_id_; @@ -73,11 +67,9 @@ class AtomPermissionManager::PendingRequest { size_t remaining_results_; }; -AtomPermissionManager::AtomPermissionManager() { -} +AtomPermissionManager::AtomPermissionManager() {} -AtomPermissionManager::~AtomPermissionManager() { -} +AtomPermissionManager::~AtomPermissionManager() {} void AtomPermissionManager::SetPermissionRequestHandler( const RequestHandler& handler) { @@ -99,13 +91,9 @@ int AtomPermissionManager::RequestPermission( const GURL& requesting_origin, bool user_gesture, const StatusCallback& response_callback) { - return RequestPermissionWithDetails( - permission, - render_frame_host, - requesting_origin, - user_gesture, - nullptr, - response_callback); + return RequestPermissionWithDetails(permission, render_frame_host, + requesting_origin, user_gesture, nullptr, + response_callback); } int AtomPermissionManager::RequestPermissionWithDetails( @@ -116,11 +104,8 @@ int AtomPermissionManager::RequestPermissionWithDetails( const base::DictionaryValue* details, const StatusCallback& response_callback) { return RequestPermissionsWithDetails( - std::vector(1, permission), - render_frame_host, - requesting_origin, - user_gesture, - details, + std::vector(1, permission), render_frame_host, + requesting_origin, user_gesture, details, base::Bind(&PermissionRequestResponseCallbackWrapper, response_callback)); } @@ -130,9 +115,9 @@ int AtomPermissionManager::RequestPermissions( const GURL& requesting_origin, bool user_gesture, const StatusesCallback& response_callback) { - return RequestPermissionsWithDetails( - permissions, render_frame_host, requesting_origin, - user_gesture, nullptr, response_callback); + return RequestPermissionsWithDetails(permissions, render_frame_host, + requesting_origin, user_gesture, nullptr, + response_callback); } int AtomPermissionManager::RequestPermissionsWithDetails( @@ -151,8 +136,9 @@ int AtomPermissionManager::RequestPermissionsWithDetails( std::vector statuses; for (auto permission : permissions) { if (permission == content::PermissionType::MIDI_SYSEX) { - content::ChildProcessSecurityPolicy::GetInstance()-> - GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID()); + content::ChildProcessSecurityPolicy::GetInstance() + ->GrantSendMidiSysExMessage( + render_frame_host->GetProcess()->GetID()); } statuses.push_back(blink::mojom::PermissionStatus::GRANTED); } @@ -168,8 +154,8 @@ int AtomPermissionManager::RequestPermissionsWithDetails( for (size_t i = 0; i < permissions.size(); ++i) { auto permission = permissions[i]; if (permission == content::PermissionType::MIDI_SYSEX) { - content::ChildProcessSecurityPolicy::GetInstance()-> - GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID()); + content::ChildProcessSecurityPolicy::GetInstance() + ->GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID()); } const auto callback = base::Bind(&AtomPermissionManager::OnPermissionResponse, @@ -210,11 +196,9 @@ void AtomPermissionManager::CancelPermissionRequest(int request_id) { pending_requests_.Remove(request_id); } -void AtomPermissionManager::ResetPermission( - content::PermissionType permission, - const GURL& requesting_origin, - const GURL& embedding_origin) { -} +void AtomPermissionManager::ResetPermission(content::PermissionType permission, + const GURL& requesting_origin, + const GURL& embedding_origin) {} blink::mojom::PermissionStatus AtomPermissionManager::GetPermissionStatus( content::PermissionType permission, @@ -232,7 +216,6 @@ int AtomPermissionManager::SubscribePermissionStatusChange( } void AtomPermissionManager::UnsubscribePermissionStatusChange( - int subscription_id) { -} + int subscription_id) {} } // namespace atom diff --git a/atom/browser/atom_permission_manager.h b/atom/browser/atom_permission_manager.h index dbeecc3da13..1b955f2351f 100644 --- a/atom/browser/atom_permission_manager.h +++ b/atom/browser/atom_permission_manager.h @@ -24,15 +24,13 @@ class AtomPermissionManager : public content::PermissionManager { AtomPermissionManager(); ~AtomPermissionManager() override; - using StatusCallback = - base::Callback; + using StatusCallback = base::Callback; using StatusesCallback = base::Callback&)>; - using RequestHandler = - base::Callback; + using RequestHandler = base::Callback; // Handler to dispatch permission requests in JS. void SetPermissionRequestHandler(const RequestHandler& handler); @@ -57,8 +55,8 @@ class AtomPermissionManager : public content::PermissionManager { content::RenderFrameHost* render_frame_host, const GURL& requesting_origin, bool user_gesture, - const base::Callback&)>& callback) + const base::Callback< + void(const std::vector&)>& callback) override; int RequestPermissionsWithDetails( const std::vector& permissions, @@ -66,8 +64,8 @@ class AtomPermissionManager : public content::PermissionManager { const GURL& requesting_origin, bool user_gesture, const base::DictionaryValue* details, - const base::Callback&)>& callback); + const base::Callback< + void(const std::vector&)>& callback); protected: void OnPermissionResponse(int request_id, diff --git a/atom/browser/atom_quota_permission_context.cc b/atom/browser/atom_quota_permission_context.cc index 8775f950ca9..ad9722c4959 100644 --- a/atom/browser/atom_quota_permission_context.cc +++ b/atom/browser/atom_quota_permission_context.cc @@ -8,11 +8,9 @@ namespace atom { -AtomQuotaPermissionContext::AtomQuotaPermissionContext() { -} +AtomQuotaPermissionContext::AtomQuotaPermissionContext() {} -AtomQuotaPermissionContext::~AtomQuotaPermissionContext() { -} +AtomQuotaPermissionContext::~AtomQuotaPermissionContext() {} void AtomQuotaPermissionContext::RequestQuotaPermission( const content::StorageQuotaParams& params, diff --git a/atom/browser/atom_quota_permission_context.h b/atom/browser/atom_quota_permission_context.h index 1246ea7bad5..378f597c75c 100644 --- a/atom/browser/atom_quota_permission_context.h +++ b/atom/browser/atom_quota_permission_context.h @@ -17,10 +17,9 @@ class AtomQuotaPermissionContext : public content::QuotaPermissionContext { virtual ~AtomQuotaPermissionContext(); // content::QuotaPermissionContext: - void RequestQuotaPermission( - const content::StorageQuotaParams& params, - int render_process_id, - const PermissionCallback& callback) override; + void RequestQuotaPermission(const content::StorageQuotaParams& params, + int render_process_id, + const PermissionCallback& callback) override; private: DISALLOW_COPY_AND_ASSIGN(AtomQuotaPermissionContext); diff --git a/atom/browser/atom_resource_dispatcher_host_delegate.cc b/atom/browser/atom_resource_dispatcher_host_delegate.cc index 046f6e45f58..993a7734eb7 100644 --- a/atom/browser/atom_resource_dispatcher_host_delegate.cc +++ b/atom/browser/atom_resource_dispatcher_host_delegate.cc @@ -32,7 +32,6 @@ #include "net/url_request/url_request.h" #endif // defined(ENABLE_PDF_VIEWER) - using content::BrowserThread; namespace atom { diff --git a/atom/browser/atom_speech_recognition_manager_delegate.cc b/atom/browser/atom_speech_recognition_manager_delegate.cc index d879eb9c6e9..8333211d9ed 100644 --- a/atom/browser/atom_speech_recognition_manager_delegate.cc +++ b/atom/browser/atom_speech_recognition_manager_delegate.cc @@ -10,45 +10,37 @@ namespace atom { -AtomSpeechRecognitionManagerDelegate::AtomSpeechRecognitionManagerDelegate() { -} +AtomSpeechRecognitionManagerDelegate::AtomSpeechRecognitionManagerDelegate() {} -AtomSpeechRecognitionManagerDelegate::~AtomSpeechRecognitionManagerDelegate() { -} +AtomSpeechRecognitionManagerDelegate::~AtomSpeechRecognitionManagerDelegate() {} -void AtomSpeechRecognitionManagerDelegate::OnRecognitionStart(int session_id) { -} +void AtomSpeechRecognitionManagerDelegate::OnRecognitionStart(int session_id) {} -void AtomSpeechRecognitionManagerDelegate::OnAudioStart(int session_id) { -} +void AtomSpeechRecognitionManagerDelegate::OnAudioStart(int session_id) {} void AtomSpeechRecognitionManagerDelegate::OnEnvironmentEstimationComplete( - int session_id) { -} + int session_id) {} -void AtomSpeechRecognitionManagerDelegate::OnSoundStart(int session_id) { -} +void AtomSpeechRecognitionManagerDelegate::OnSoundStart(int session_id) {} -void AtomSpeechRecognitionManagerDelegate::OnSoundEnd(int session_id) { -} +void AtomSpeechRecognitionManagerDelegate::OnSoundEnd(int session_id) {} -void AtomSpeechRecognitionManagerDelegate::OnAudioEnd(int session_id) { -} +void AtomSpeechRecognitionManagerDelegate::OnAudioEnd(int session_id) {} -void AtomSpeechRecognitionManagerDelegate::OnRecognitionEnd(int session_id) { -} +void AtomSpeechRecognitionManagerDelegate::OnRecognitionEnd(int session_id) {} void AtomSpeechRecognitionManagerDelegate::OnRecognitionResults( - int session_id, const content::SpeechRecognitionResults& result) { -} + int session_id, + const content::SpeechRecognitionResults& result) {} void AtomSpeechRecognitionManagerDelegate::OnRecognitionError( - int session_id, const content::SpeechRecognitionError& error) { -} + int session_id, + const content::SpeechRecognitionError& error) {} void AtomSpeechRecognitionManagerDelegate::OnAudioLevelsChange( - int session_id, float volume, float noise_volume) { -} + int session_id, + float volume, + float noise_volume) {} void AtomSpeechRecognitionManagerDelegate::CheckRecognitionIsAllowed( int session_id, diff --git a/atom/browser/atom_speech_recognition_manager_delegate.h b/atom/browser/atom_speech_recognition_manager_delegate.h index 860cbc675d3..011f5dde602 100644 --- a/atom/browser/atom_speech_recognition_manager_delegate.h +++ b/atom/browser/atom_speech_recognition_manager_delegate.h @@ -29,10 +29,13 @@ class AtomSpeechRecognitionManagerDelegate void OnAudioEnd(int session_id) override; void OnRecognitionEnd(int session_id) override; void OnRecognitionResults( - int session_id, const content::SpeechRecognitionResults& result) override; + int session_id, + const content::SpeechRecognitionResults& result) override; void OnRecognitionError( - int session_id, const content::SpeechRecognitionError& error) override; - void OnAudioLevelsChange(int session_id, float volume, + int session_id, + const content::SpeechRecognitionError& error) override; + void OnAudioLevelsChange(int session_id, + float volume, float noise_volume) override; // content::SpeechRecognitionManagerDelegate: diff --git a/atom/browser/atom_web_ui_controller_factory.cc b/atom/browser/atom_web_ui_controller_factory.cc index dc7718f52ac..b4e8c1b130a 100644 --- a/atom/browser/atom_web_ui_controller_factory.cc +++ b/atom/browser/atom_web_ui_controller_factory.cc @@ -60,9 +60,9 @@ AtomWebUIControllerFactory::CreateWebUIControllerForURL(content::WebUI* web_ui, std::string src; const net::UnescapeRule::Type unescape_rules = - net::UnescapeRule::SPACES | net::UnescapeRule::PATH_SEPARATORS | - net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS | - net::UnescapeRule::REPLACE_PLUS_WITH_SPACE; + net::UnescapeRule::SPACES | net::UnescapeRule::PATH_SEPARATORS | + net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS | + net::UnescapeRule::REPLACE_PLUS_WITH_SPACE; for (const auto& param : toplevel_params) { if (param.first == kPdfPluginSrc) { diff --git a/atom/browser/auto_updater.cc b/atom/browser/auto_updater.cc index 4dc1818cfb8..90ff1574778 100644 --- a/atom/browser/auto_updater.cc +++ b/atom/browser/auto_updater.cc @@ -21,14 +21,11 @@ std::string AutoUpdater::GetFeedURL() { return ""; } -void AutoUpdater::SetFeedURL(mate::Arguments* args) { -} +void AutoUpdater::SetFeedURL(mate::Arguments* args) {} -void AutoUpdater::CheckForUpdates() { -} +void AutoUpdater::CheckForUpdates() {} -void AutoUpdater::QuitAndInstall() { -} +void AutoUpdater::QuitAndInstall() {} #endif } // namespace auto_updater diff --git a/atom/browser/auto_updater.h b/atom/browser/auto_updater.h index ae9178585a7..7be3e56db3e 100644 --- a/atom/browser/auto_updater.h +++ b/atom/browser/auto_updater.h @@ -23,7 +23,8 @@ class Delegate { // An error happened. virtual void OnError(const std::string& error) {} - virtual void OnError(const std::string& error, const int code, + virtual void OnError(const std::string& error, + const int code, const std::string& domain) {} // Checking to see if there is an update diff --git a/atom/browser/bridge_task_runner.cc b/atom/browser/bridge_task_runner.cc index f0a6206f346..829b4a38257 100644 --- a/atom/browser/bridge_task_runner.cc +++ b/atom/browser/bridge_task_runner.cc @@ -21,18 +21,17 @@ void BridgeTaskRunner::MessageLoopIsReady() { } } -bool BridgeTaskRunner::PostDelayedTask( - const base::Location& from_here, - base::OnceClosure task, - base::TimeDelta delay) { +bool BridgeTaskRunner::PostDelayedTask(const base::Location& from_here, + base::OnceClosure task, + base::TimeDelta delay) { auto message_loop = base::MessageLoop::current(); if (!message_loop) { tasks_.push_back(std::make_tuple(from_here, std::move(task), delay)); return true; } - return message_loop->task_runner()->PostDelayedTask( - from_here, std::move(task), delay); + return message_loop->task_runner()->PostDelayedTask(from_here, + std::move(task), delay); } bool BridgeTaskRunner::RunsTasksInCurrentSequence() const { @@ -49,8 +48,8 @@ bool BridgeTaskRunner::PostNonNestableDelayedTask( base::TimeDelta delay) { auto message_loop = base::MessageLoop::current(); if (!message_loop) { - non_nestable_tasks_.push_back(std::make_tuple( - from_here, std::move(task), delay)); + non_nestable_tasks_.push_back( + std::make_tuple(from_here, std::move(task), delay)); return true; } diff --git a/atom/browser/bridge_task_runner.h b/atom/browser/bridge_task_runner.h index cf04daa6f1c..70a3d7f5987 100644 --- a/atom/browser/bridge_task_runner.h +++ b/atom/browser/bridge_task_runner.h @@ -29,14 +29,13 @@ class BridgeTaskRunner : public base::SingleThreadTaskRunner { base::OnceClosure task, base::TimeDelta delay) override; bool RunsTasksInCurrentSequence() const override; - bool PostNonNestableDelayedTask( - const base::Location& from_here, - base::OnceClosure task, - base::TimeDelta delay) override; + bool PostNonNestableDelayedTask(const base::Location& from_here, + base::OnceClosure task, + base::TimeDelta delay) override; private: - using TaskPair = std::tuple< - base::Location, base::OnceClosure, base::TimeDelta>; + using TaskPair = + std::tuple; std::vector tasks_; std::vector non_nestable_tasks_; diff --git a/atom/browser/browser.h b/atom/browser/browser.h index a8c1a8c5e7c..a6d3baa2b3a 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -229,13 +229,9 @@ class Browser : public WindowListObserver { void PreMainMessageLoopRun(); - void AddObserver(BrowserObserver* obs) { - observers_.AddObserver(obs); - } + void AddObserver(BrowserObserver* obs) { observers_.AddObserver(obs); } - void RemoveObserver(BrowserObserver* obs) { - observers_.RemoveObserver(obs); - } + void RemoveObserver(BrowserObserver* obs) { observers_.RemoveObserver(obs); } bool is_shutting_down() const { return is_shutdown_; } bool is_quiting() const { return is_quiting_; } diff --git a/atom/browser/browser_linux.cc b/atom/browser/browser_linux.cc index 42cdcc043d7..6acea531708 100644 --- a/atom/browser/browser_linux.cc +++ b/atom/browser/browser_linux.cc @@ -28,7 +28,8 @@ const char kXdgSettingsDefaultSchemeHandler[] = "default-url-scheme-handler"; bool LaunchXdgUtility(const std::vector& argv, int* exit_code) { *exit_code = EXIT_FAILURE; int devnull = open("/dev/null", O_RDONLY); - if (devnull < 0) return false; + if (devnull < 0) + return false; base::LaunchOptions options; options.fds_to_remap.push_back(std::make_pair(devnull, STDIN_FILENO)); @@ -36,7 +37,8 @@ bool LaunchXdgUtility(const std::vector& argv, int* exit_code) { base::Process process = base::LaunchProcess(argv, options); close(devnull); - if (!process.IsValid()) return false; + if (!process.IsValid()) + return false; return process.WaitForExit(exit_code); } @@ -67,14 +69,11 @@ void Browser::Focus() { } } -void Browser::AddRecentDocument(const base::FilePath& path) { -} +void Browser::AddRecentDocument(const base::FilePath& path) {} -void Browser::ClearRecentDocuments() { -} +void Browser::ClearRecentDocuments() {} -void Browser::SetAppUserModelID(const base::string16& name) { -} +void Browser::SetAppUserModelID(const base::string16& name) {} bool Browser::SetAsDefaultProtocolClient(const std::string& protocol, mate::Arguments* args) { @@ -85,7 +84,8 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol, mate::Arguments* args) { std::unique_ptr env(base::Environment::Create()); - if (protocol.empty()) return false; + if (protocol.empty()) + return false; std::vector argv; argv.push_back(kXdgSettings); @@ -96,15 +96,15 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol, std::string reply; int success_code; - bool ran_ok = base::GetAppOutputWithExitCode(base::CommandLine(argv), - &reply, &success_code); + bool ran_ok = base::GetAppOutputWithExitCode(base::CommandLine(argv), &reply, + &success_code); - if (!ran_ok || success_code != EXIT_SUCCESS) return false; + if (!ran_ok || success_code != EXIT_SUCCESS) + return false; // Allow any reply that starts with "yes". - return base::StartsWith(reply, "yes", base::CompareCase::SENSITIVE) - ? true - : false; + return base::StartsWith(reply, "yes", base::CompareCase::SENSITIVE) ? true + : false; } // Todo implement @@ -123,8 +123,7 @@ bool Browser::SetBadgeCount(int count) { } } -void Browser::SetLoginItemSettings(LoginItemSettings settings) { -} +void Browser::SetLoginItemSettings(LoginItemSettings settings) {} Browser::LoginItemSettings Browser::GetLoginItemSettings( const LoginItemSettings& options) { diff --git a/atom/browser/browser_observer.h b/atom/browser/browser_observer.h index 987e37115e7..fb47492aef5 100644 --- a/atom/browser/browser_observer.h +++ b/atom/browser/browser_observer.h @@ -34,8 +34,8 @@ class BrowserObserver { // The browser has opened a file by double clicking in Finder or dragging the // file to the Dock icon. (macOS only) - virtual void OnOpenFile(bool* prevent_default, - const std::string& file_path) {} + virtual void OnOpenFile(bool* prevent_default, const std::string& file_path) { + } // Browser is used to open a url. virtual void OnOpenURL(const std::string& url) {} @@ -60,18 +60,15 @@ class BrowserObserver { #if defined(OS_MACOSX) // The browser wants to report that an user activity will resume. (macOS only) - virtual void OnWillContinueUserActivity( - bool* prevent_default, - const std::string& type) {} + virtual void OnWillContinueUserActivity(bool* prevent_default, + const std::string& type) {} // The browser wants to report an user activity resuming error. (macOS only) - virtual void OnDidFailToContinueUserActivity( - const std::string& type, - const std::string& error) {} + virtual void OnDidFailToContinueUserActivity(const std::string& type, + const std::string& error) {} // The browser wants to resume a user activity via handoff. (macOS only) - virtual void OnContinueUserActivity( - bool* prevent_default, - const std::string& type, - const base::DictionaryValue& user_info) {} + virtual void OnContinueUserActivity(bool* prevent_default, + const std::string& type, + const base::DictionaryValue& user_info) {} // The browser wants to notify that an user activity was resumed. (macOS only) virtual void OnUserActivityWasContinued( const std::string& type, diff --git a/atom/browser/browser_win.cc b/atom/browser/browser_win.cc index f27e3dfa139..d109129afbb 100644 --- a/atom/browser/browser_win.cc +++ b/atom/browser/browser_win.cc @@ -61,8 +61,7 @@ bool GetProtocolLaunchPath(mate::Arguments* args, base::string16* exe) { // Read in optional args arg std::vector launch_args; if (args->GetNext(&launch_args) && !launch_args.empty()) - *exe = base::StringPrintf(L"\"%ls\" %ls \"%%1\"", - exe->c_str(), + *exe = base::StringPrintf(L"\"%ls\" %ls \"%%1\"", exe->c_str(), base::JoinString(launch_args, L" ").c_str()); else *exe = base::StringPrintf(L"\"%ls\" \"%%1\"", exe->c_str()); @@ -76,8 +75,7 @@ bool FormatCommandLineString(base::string16* exe, } if (!launch_args.empty()) { - *exe = base::StringPrintf(L"%ls %ls", - exe->c_str(), + *exe = base::StringPrintf(L"%ls %ls", exe->c_str(), base::JoinString(launch_args, L" ").c_str()); } @@ -97,8 +95,8 @@ void Browser::AddRecentDocument(const base::FilePath& path) { return; CComPtr item; - HRESULT hr = SHCreateItemFromParsingName( - path.value().c_str(), NULL, IID_PPV_ARGS(&item)); + HRESULT hr = SHCreateItemFromParsingName(path.value().c_str(), NULL, + IID_PPV_ARGS(&item)); if (SUCCEEDED(hr)) { SHARDAPPIDINFO info; info.psi = item; @@ -109,8 +107,8 @@ void Browser::AddRecentDocument(const base::FilePath& path) { void Browser::ClearRecentDocuments() { CComPtr destinations; - if (FAILED(destinations.CoCreateInstance(CLSID_ApplicationDestinations, - NULL, CLSCTX_INPROC_SERVER))) + if (FAILED(destinations.CoCreateInstance(CLSID_ApplicationDestinations, NULL, + CLSCTX_INPROC_SERVER))) return; if (FAILED(destinations->SetAppID(GetAppUserModelID()))) return; @@ -189,8 +187,8 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol, base::win::RegKey protocolKey; base::string16 protocolPath = keyPath + wprotocol; - if (SUCCEEDED(protocolKey - .Open(root, protocolPath.c_str(), KEY_ALL_ACCESS))) { + if (SUCCEEDED( + protocolKey.Open(root, protocolPath.c_str(), KEY_ALL_ACCESS))) { protocolKey.DeleteValue(L"URL Protocol"); // Overwrite the default value to be empty, we can't delete it right away @@ -208,7 +206,7 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol, } bool Browser::SetAsDefaultProtocolClient(const std::string& protocol, - mate::Arguments* args) { + mate::Arguments* args) { // HKEY_CLASSES_ROOT // $PROTOCOL // (Default) = "URL:$NAME" diff --git a/atom/browser/common_web_contents_delegate.cc b/atom/browser/common_web_contents_delegate.cc index 4737d687c47..2765c722e21 100644 --- a/atom/browser/common_web_contents_delegate.cc +++ b/atom/browser/common_web_contents_delegate.cc @@ -42,15 +42,13 @@ namespace { const char kRootName[] = ""; struct FileSystem { - FileSystem() { - } + FileSystem() {} FileSystem(const std::string& file_system_name, const std::string& root_url, const std::string& file_system_path) - : file_system_name(file_system_name), - root_url(root_url), - file_system_path(file_system_path) { - } + : file_system_name(file_system_name), + root_url(root_url), + file_system_path(file_system_path) {} std::string file_system_name; std::string root_url; @@ -62,10 +60,7 @@ std::string RegisterFileSystem(content::WebContents* web_contents, auto isolated_context = storage::IsolatedContext::GetInstance(); std::string root_name(kRootName); std::string file_system_id = isolated_context->RegisterFileSystemForPath( - storage::kFileSystemTypeNativeLocal, - std::string(), - path, - &root_name); + storage::kFileSystemTypeNativeLocal, std::string(), path, &root_name); content::ChildProcessSecurityPolicy* policy = content::ChildProcessSecurityPolicy::GetInstance(); @@ -82,10 +77,9 @@ std::string RegisterFileSystem(content::WebContents* web_contents, return file_system_id; } -FileSystem CreateFileSystemStruct( - content::WebContents* web_contents, - const std::string& file_system_id, - const std::string& file_system_path) { +FileSystem CreateFileSystemStruct(content::WebContents* web_contents, + const std::string& file_system_id, + const std::string& file_system_path) { const GURL origin = web_contents->GetURL().GetOrigin(); std::string file_system_name = storage::GetIsolatedFileSystemName(origin, file_system_id); @@ -104,16 +98,14 @@ std::unique_ptr CreateFileSystemValue( return file_system_value; } -void WriteToFile(const base::FilePath& path, - const std::string& content) { +void WriteToFile(const base::FilePath& path, const std::string& content) { DCHECK_CURRENTLY_ON(BrowserThread::FILE); DCHECK(!path.empty()); base::WriteFile(path, content.data(), content.size()); } -void AppendToFile(const base::FilePath& path, - const std::string& content) { +void AppendToFile(const base::FilePath& path, const std::string& content) { DCHECK_CURRENTLY_ON(BrowserThread::FILE); DCHECK(!path.empty()); @@ -140,9 +132,8 @@ std::set GetAddedFileSystemPaths( return result; } -bool IsDevToolsFileSystemAdded( - content::WebContents* web_contents, - const std::string& file_system_path) { +bool IsDevToolsFileSystemAdded(content::WebContents* web_contents, + const std::string& file_system_path) { auto file_system_paths = GetAddedFileSystemPaths(web_contents); return file_system_paths.find(file_system_path) != file_system_paths.end(); } @@ -154,11 +145,9 @@ CommonWebContentsDelegate::CommonWebContentsDelegate() ignore_menu_shortcuts_(false), html_fullscreen_(false), native_fullscreen_(false), - devtools_file_system_indexer_(new DevToolsFileSystemIndexer) { -} + devtools_file_system_indexer_(new DevToolsFileSystemIndexer) {} -CommonWebContentsDelegate::~CommonWebContentsDelegate() { -} +CommonWebContentsDelegate::~CommonWebContentsDelegate() {} void CommonWebContentsDelegate::InitWithWebContents( content::WebContents* web_contents, @@ -183,7 +172,8 @@ void CommonWebContentsDelegate::SetOwnerWindow(NativeWindow* owner_window) { } void CommonWebContentsDelegate::SetOwnerWindow( - content::WebContents* web_contents, NativeWindow* owner_window) { + content::WebContents* web_contents, + NativeWindow* owner_window) { owner_window_ = owner_window ? owner_window->GetWeakPtr() : nullptr; auto relay = std::make_unique(owner_window_); auto relay_key = relay->key; @@ -213,8 +203,8 @@ content::WebContents* CommonWebContentsDelegate::GetWebContents() const { return web_contents_->GetWebContents(); } -content::WebContents* -CommonWebContentsDelegate::GetDevToolsWebContents() const { +content::WebContents* CommonWebContentsDelegate::GetDevToolsWebContents() + const { if (!web_contents_) return nullptr; return web_contents_->GetDevToolsWebContents(); @@ -264,7 +254,8 @@ void CommonWebContentsDelegate::EnumerateDirectory(content::WebContents* guest, } void CommonWebContentsDelegate::EnterFullscreenModeForTab( - content::WebContents* source, const GURL& origin) { + content::WebContents* source, + const GURL& origin) { if (!owner_window_) return; SetHtmlApiFullscreen(true); @@ -298,8 +289,9 @@ blink::WebSecurityStyle CommonWebContentsDelegate::GetSecurityStyle( security_style_explanations); } -void CommonWebContentsDelegate::DevToolsSaveToFile( - const std::string& url, const std::string& content, bool save_as) { +void CommonWebContentsDelegate::DevToolsSaveToFile(const std::string& url, + const std::string& content, + bool save_as) { base::FilePath path; auto it = saved_files_.find(url); if (it != saved_files_.end() && !save_as) { @@ -312,22 +304,22 @@ void CommonWebContentsDelegate::DevToolsSaveToFile( settings.default_path = base::FilePath::FromUTF8Unsafe(url); if (!file_dialog::ShowSaveDialog(settings, &path)) { base::Value url_value(url); - web_contents_->CallClientFunction( - "DevToolsAPI.canceledSaveURL", &url_value, nullptr, nullptr); + web_contents_->CallClientFunction("DevToolsAPI.canceledSaveURL", + &url_value, nullptr, nullptr); return; } } saved_files_[url] = path; BrowserThread::PostTaskAndReply( - BrowserThread::FILE, FROM_HERE, - base::Bind(&WriteToFile, path, content), + BrowserThread::FILE, FROM_HERE, base::Bind(&WriteToFile, path, content), base::Bind(&CommonWebContentsDelegate::OnDevToolsSaveToFile, base::Unretained(this), url)); } void CommonWebContentsDelegate::DevToolsAppendToFile( - const std::string& url, const std::string& content) { + const std::string& url, + const std::string& content) { auto it = saved_files_.find(url); if (it == saved_files_.end()) return; @@ -344,19 +336,18 @@ void CommonWebContentsDelegate::DevToolsRequestFileSystems() { if (file_system_paths.empty()) { base::ListValue empty_file_system_value; web_contents_->CallClientFunction("DevToolsAPI.fileSystemsLoaded", - &empty_file_system_value, - nullptr, nullptr); + &empty_file_system_value, nullptr, + nullptr); return; } std::vector file_systems; for (const auto& file_system_path : file_system_paths) { base::FilePath path = base::FilePath::FromUTF8Unsafe(file_system_path); - std::string file_system_id = RegisterFileSystem(GetDevToolsWebContents(), - path); - FileSystem file_system = CreateFileSystemStruct(GetDevToolsWebContents(), - file_system_id, - file_system_path); + std::string file_system_id = + RegisterFileSystem(GetDevToolsWebContents(), path); + FileSystem file_system = CreateFileSystemStruct( + GetDevToolsWebContents(), file_system_id, file_system_path); file_systems.push_back(file_system); } @@ -382,25 +373,23 @@ void CommonWebContentsDelegate::DevToolsAddFileSystem( path = paths[0]; } - std::string file_system_id = RegisterFileSystem(GetDevToolsWebContents(), - path); + std::string file_system_id = + RegisterFileSystem(GetDevToolsWebContents(), path); if (IsDevToolsFileSystemAdded(GetDevToolsWebContents(), path.AsUTF8Unsafe())) return; - FileSystem file_system = CreateFileSystemStruct(GetDevToolsWebContents(), - file_system_id, - path.AsUTF8Unsafe()); + FileSystem file_system = CreateFileSystemStruct( + GetDevToolsWebContents(), file_system_id, path.AsUTF8Unsafe()); std::unique_ptr file_system_value( CreateFileSystemValue(file_system)); auto pref_service = GetPrefService(GetDevToolsWebContents()); DictionaryPrefUpdate update(pref_service, prefs::kDevToolsFileSystemPaths); - update.Get()->SetWithoutPathExpansion( - path.AsUTF8Unsafe(), std::make_unique()); + update.Get()->SetWithoutPathExpansion(path.AsUTF8Unsafe(), + std::make_unique()); web_contents_->CallClientFunction("DevToolsAPI.fileSystemAdded", - file_system_value.get(), - nullptr, nullptr); + file_system_value.get(), nullptr, nullptr); } void CommonWebContentsDelegate::DevToolsRemoveFileSystem( @@ -409,8 +398,8 @@ void CommonWebContentsDelegate::DevToolsRemoveFileSystem( return; std::string path = file_system_path.AsUTF8Unsafe(); - storage::IsolatedContext::GetInstance()-> - RevokeFileSystemByPath(file_system_path); + storage::IsolatedContext::GetInstance()->RevokeFileSystemByPath( + file_system_path); auto pref_service = GetPrefService(GetDevToolsWebContents()); DictionaryPrefUpdate update(pref_service, prefs::kDevToolsFileSystemPaths); @@ -418,8 +407,7 @@ void CommonWebContentsDelegate::DevToolsRemoveFileSystem( base::Value file_system_path_value(path); web_contents_->CallClientFunction("DevToolsAPI.fileSystemRemoved", - &file_system_path_value, - nullptr, nullptr); + &file_system_path_value, nullptr, nullptr); } void CommonWebContentsDelegate::DevToolsIndexPath( @@ -437,16 +425,11 @@ void CommonWebContentsDelegate::DevToolsIndexPath( file_system_path, base::Bind( &CommonWebContentsDelegate::OnDevToolsIndexingWorkCalculated, - base::Unretained(this), - request_id, - file_system_path), + base::Unretained(this), request_id, file_system_path), base::Bind(&CommonWebContentsDelegate::OnDevToolsIndexingWorked, - base::Unretained(this), - request_id, - file_system_path), + base::Unretained(this), request_id, file_system_path), base::Bind(&CommonWebContentsDelegate::OnDevToolsIndexingDone, - base::Unretained(this), - request_id, + base::Unretained(this), request_id, file_system_path))); } @@ -463,34 +446,28 @@ void CommonWebContentsDelegate::DevToolsSearchInPath( const std::string& file_system_path, const std::string& query) { if (!IsDevToolsFileSystemAdded(GetDevToolsWebContents(), file_system_path)) { - OnDevToolsSearchCompleted(request_id, - file_system_path, + OnDevToolsSearchCompleted(request_id, file_system_path, std::vector()); return; } devtools_file_system_indexer_->SearchInPath( - file_system_path, - query, + file_system_path, query, base::Bind(&CommonWebContentsDelegate::OnDevToolsSearchCompleted, - base::Unretained(this), - request_id, - file_system_path)); + base::Unretained(this), request_id, file_system_path)); } -void CommonWebContentsDelegate::OnDevToolsSaveToFile( - const std::string& url) { +void CommonWebContentsDelegate::OnDevToolsSaveToFile(const std::string& url) { // Notify DevTools. base::Value url_value(url); - web_contents_->CallClientFunction( - "DevToolsAPI.savedURL", &url_value, nullptr, nullptr); + web_contents_->CallClientFunction("DevToolsAPI.savedURL", &url_value, nullptr, + nullptr); } -void CommonWebContentsDelegate::OnDevToolsAppendToFile( - const std::string& url) { +void CommonWebContentsDelegate::OnDevToolsAppendToFile(const std::string& url) { // Notify DevTools. base::Value url_value(url); - web_contents_->CallClientFunction( - "DevToolsAPI.appendedToURL", &url_value, nullptr, nullptr); + web_contents_->CallClientFunction("DevToolsAPI.appendedToURL", &url_value, + nullptr, nullptr); } void CommonWebContentsDelegate::OnDevToolsIndexingWorkCalculated( @@ -501,8 +478,7 @@ void CommonWebContentsDelegate::OnDevToolsIndexingWorkCalculated( base::Value file_system_path_value(file_system_path); base::Value total_work_value(total_work); web_contents_->CallClientFunction("DevToolsAPI.indexingTotalWorkCalculated", - &request_id_value, - &file_system_path_value, + &request_id_value, &file_system_path_value, &total_work_value); } @@ -514,8 +490,7 @@ void CommonWebContentsDelegate::OnDevToolsIndexingWorked( base::Value file_system_path_value(file_system_path); base::Value worked_value(worked); web_contents_->CallClientFunction("DevToolsAPI.indexingWorked", - &request_id_value, - &file_system_path_value, + &request_id_value, &file_system_path_value, &worked_value); } @@ -526,8 +501,7 @@ void CommonWebContentsDelegate::OnDevToolsIndexingDone( base::Value request_id_value(request_id); base::Value file_system_path_value(file_system_path); web_contents_->CallClientFunction("DevToolsAPI.indexingDone", - &request_id_value, - &file_system_path_value, + &request_id_value, &file_system_path_value, nullptr); } @@ -542,8 +516,7 @@ void CommonWebContentsDelegate::OnDevToolsSearchCompleted( base::Value request_id_value(request_id); base::Value file_system_path_value(file_system_path); web_contents_->CallClientFunction("DevToolsAPI.searchCompleted", - &request_id_value, - &file_system_path_value, + &request_id_value, &file_system_path_value, &file_paths_value); } diff --git a/atom/browser/common_web_contents_delegate.h b/atom/browser/common_web_contents_delegate.h index 53575f82a82..79030ab85ac 100644 --- a/atom/browser/common_web_contents_delegate.h +++ b/atom/browser/common_web_contents_delegate.h @@ -92,12 +92,11 @@ class CommonWebContentsDelegate // Autofill related events. #if defined(TOOLKIT_VIEWS) - void ShowAutofillPopup( - bool offscreen, - content::RenderFrameHost* frame_host, - const gfx::RectF& bounds, - const std::vector& values, - const std::vector& labels); + void ShowAutofillPopup(bool offscreen, + content::RenderFrameHost* frame_host, + const gfx::RectF& bounds, + const std::vector& values, + const std::vector& labels); void HideAutofillPopup(); #endif @@ -123,8 +122,8 @@ class CommonWebContentsDelegate gfx::ImageSkia GetDevToolsWindowIcon() override; #endif #if defined(USE_X11) - void GetDevToolsWindowWMClass( - std::string* name, std::string* class_name) override; + void GetDevToolsWindowWMClass(std::string* name, + std::string* class_name) override; #endif // Destroy the managed InspectableWebContents object. @@ -187,10 +186,9 @@ class CommonWebContentsDelegate PathsMap saved_files_; // Map id to index job, used for file system indexing requests from devtools. - typedef std::map< - int, - scoped_refptr> - DevToolsIndexingJobsMap; + typedef std:: + map> + DevToolsIndexingJobsMap; DevToolsIndexingJobsMap devtools_indexing_jobs_; DISALLOW_COPY_AND_ASSIGN(CommonWebContentsDelegate); diff --git a/atom/browser/common_web_contents_delegate_views.cc b/atom/browser/common_web_contents_delegate_views.cc index 78009c2a8da..e81a455d678 100644 --- a/atom/browser/common_web_contents_delegate_views.cc +++ b/atom/browser/common_web_contents_delegate_views.cc @@ -37,8 +37,8 @@ void CommonWebContentsDelegate::ShowAutofillPopup( return; auto* window = static_cast(owner_window()); - autofill_popup_->CreateView( - frame_host, offscreen, window->content_view(), bounds); + autofill_popup_->CreateView(frame_host, offscreen, window->content_view(), + bounds); autofill_popup_->SetItems(values, labels); } @@ -50,13 +50,15 @@ void CommonWebContentsDelegate::HideAutofillPopup() { gfx::ImageSkia CommonWebContentsDelegate::GetDevToolsWindowIcon() { if (!owner_window()) return gfx::ImageSkia(); - return static_cast(static_cast( - owner_window()))->GetWindowAppIcon(); + return static_cast( + static_cast(owner_window())) + ->GetWindowAppIcon(); } #if defined(USE_X11) void CommonWebContentsDelegate::GetDevToolsWindowWMClass( - std::string* name, std::string* class_name) { + std::string* name, + std::string* class_name) { *class_name = Browser::Get()->GetName(); *name = base::ToLowerASCII(*class_name); } diff --git a/atom/browser/javascript_environment.cc b/atom/browser/javascript_environment.cc index 631beb4ff61..cc666e72e61 100644 --- a/atom/browser/javascript_environment.cc +++ b/atom/browser/javascript_environment.cc @@ -27,8 +27,7 @@ JavascriptEnvironment::JavascriptEnvironment() locker_(isolate_), handle_scope_(isolate_), context_(isolate_, v8::Context::New(isolate_)), - context_scope_(v8::Local::New(isolate_, context_)) { -} + context_scope_(v8::Local::New(isolate_, context_)) {} void JavascriptEnvironment::OnMessageLoopCreated() { isolate_holder_.AddRunMicrotasksObserver(); @@ -53,15 +52,13 @@ bool JavascriptEnvironment::Initialize() { v8::V8::InitializePlatform(platform_); node::tracing::TraceEventHelper::SetTracingController( new v8::TracingController()); - gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode, - gin::IsolateHolder::kStableV8Extras, - gin::ArrayBufferAllocator::SharedInstance(), - false); + gin::IsolateHolder::Initialize( + gin::IsolateHolder::kNonStrictMode, gin::IsolateHolder::kStableV8Extras, + gin::ArrayBufferAllocator::SharedInstance(), false); return true; } -NodeEnvironment::NodeEnvironment(node::Environment* env) : env_(env) { -} +NodeEnvironment::NodeEnvironment(node::Environment* env) : env_(env) {} NodeEnvironment::~NodeEnvironment() { node::FreeEnvironment(env_); diff --git a/atom/browser/javascript_environment.h b/atom/browser/javascript_environment.h index 69872e454aa..09b22ebb838 100644 --- a/atom/browser/javascript_environment.h +++ b/atom/browser/javascript_environment.h @@ -11,7 +11,7 @@ namespace node { class Environment; class MultiIsolatePlatform; -} +} // namespace node namespace atom { diff --git a/atom/browser/lib/bluetooth_chooser.cc b/atom/browser/lib/bluetooth_chooser.cc index e41b5555af3..5a20a57884b 100644 --- a/atom/browser/lib/bluetooth_chooser.cc +++ b/atom/browser/lib/bluetooth_chooser.cc @@ -9,10 +9,11 @@ namespace mate { -template<> +template <> struct Converter { static v8::Local ToV8( - v8::Isolate* isolate, const atom::BluetoothChooser::DeviceInfo& val) { + v8::Isolate* isolate, + const atom::BluetoothChooser::DeviceInfo& val) { mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate); dict.Set("deviceName", val.device_name); dict.Set("deviceId", val.device_id); @@ -28,9 +29,8 @@ namespace { const int kMaxScanRetries = 5; -void OnDeviceChosen( - const content::BluetoothChooser::EventHandler& handler, - const std::string& device_id) { +void OnDeviceChosen(const content::BluetoothChooser::EventHandler& handler, + const std::string& device_id) { if (device_id.empty()) { handler.Run(content::BluetoothChooser::Event::CANCELLED, device_id); } else { @@ -40,16 +40,13 @@ void OnDeviceChosen( } // namespace -BluetoothChooser::BluetoothChooser( - api::WebContents* contents, - const EventHandler& event_handler) +BluetoothChooser::BluetoothChooser(api::WebContents* contents, + const EventHandler& event_handler) : api_web_contents_(contents), event_handler_(event_handler), - num_retries_(0) { -} + num_retries_(0) {} -BluetoothChooser::~BluetoothChooser() { -} +BluetoothChooser::~BluetoothChooser() {} void BluetoothChooser::SetAdapterPresence(AdapterPresence presence) { switch (presence) { @@ -69,15 +66,13 @@ void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) { break; case DiscoveryState::IDLE: if (device_list_.empty()) { - auto event = ++num_retries_ > kMaxScanRetries ? Event::CANCELLED - : Event::RESCAN; + auto event = + ++num_retries_ > kMaxScanRetries ? Event::CANCELLED : Event::RESCAN; event_handler_.Run(event, ""); } else { - bool prevent_default = - api_web_contents_->Emit("select-bluetooth-device", - device_list_, - base::Bind(&OnDeviceChosen, - event_handler_)); + bool prevent_default = api_web_contents_->Emit( + "select-bluetooth-device", device_list_, + base::Bind(&OnDeviceChosen, event_handler_)); if (!prevent_default) { auto device_id = device_list_[0].device_id; event_handler_.Run(Event::SELECTED, device_id); @@ -100,8 +95,9 @@ void BluetoothChooser::AddOrUpdateDevice(const std::string& device_id, // Emit a select-bluetooth-device handler to allow for user to listen for // bluetooth device found. - bool prevent_default = api_web_contents_->Emit("select-bluetooth-device", - device_list_, base::Bind(&OnDeviceChosen, event_handler_)); + bool prevent_default = + api_web_contents_->Emit("select-bluetooth-device", device_list_, + base::Bind(&OnDeviceChosen, event_handler_)); // If emit not implimented select first device that matches the filters // provided. diff --git a/atom/browser/lib/power_observer_linux.cc b/atom/browser/lib/power_observer_linux.cc index 27da2b91762..a13b94e3964 100644 --- a/atom/browser/lib/power_observer_linux.cc +++ b/atom/browser/lib/power_observer_linux.cc @@ -72,7 +72,7 @@ void PowerObserverLinux::OnLoginServiceAvailable(bool service_available) { void PowerObserverLinux::BlockSleep() { dbus::MethodCall sleep_inhibit_call(kLogindManagerInterface, "Inhibit"); dbus::MessageWriter inhibit_writer(&sleep_inhibit_call); - inhibit_writer.AppendString("sleep"); // what + inhibit_writer.AppendString("sleep"); // what // Use the executable name as the lock owner, which will list rebrands of the // electron executable as separate entities. inhibit_writer.AppendString(lock_owner_name_); // who diff --git a/atom/browser/login_handler.cc b/atom/browser/login_handler.cc index 8eef00756de..5ad7ba28dfd 100644 --- a/atom/browser/login_handler.cc +++ b/atom/browser/login_handler.cc @@ -38,7 +38,7 @@ LoginHandler::LoginHandler(net::AuthChallengeInfo* auth_info, render_process_host_id_(0), render_frame_id_(0) { content::ResourceRequestInfo::ForRequest(request_)->GetAssociatedRenderFrame( - &render_process_host_id_, &render_frame_id_); + &render_process_host_id_, &render_frame_id_); // Fill request details on IO thread. std::unique_ptr request_details( @@ -47,14 +47,12 @@ LoginHandler::LoginHandler(net::AuthChallengeInfo* auth_info, BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&Browser::RequestLogin, - base::Unretained(Browser::Get()), + base::Bind(&Browser::RequestLogin, base::Unretained(Browser::Get()), base::RetainedRef(WrapRefCounted(this)), base::Passed(&request_details))); } -LoginHandler::~LoginHandler() { -} +LoginHandler::~LoginHandler() {} content::WebContents* LoginHandler::GetWebContents() const { DCHECK_CURRENTLY_ON(BrowserThread::UI); diff --git a/atom/browser/login_handler.h b/atom/browser/login_handler.h index ba1371336cc..f4cbccd7c2c 100644 --- a/atom/browser/login_handler.h +++ b/atom/browser/login_handler.h @@ -16,7 +16,7 @@ class WebContents; namespace net { class AuthChallengeInfo; class URLRequest; -} +} // namespace net namespace atom { diff --git a/atom/browser/mac/atom_application.h b/atom/browser/mac/atom_application.h index 243667b4603..5015608d6fc 100644 --- a/atom/browser/mac/atom_application.h +++ b/atom/browser/mac/atom_application.h @@ -3,12 +3,12 @@ // found in the LICENSE file. #include "base/callback.h" -#include "base/mac/scoped_sending_event.h" #include "base/mac/scoped_nsobject.h" +#include "base/mac/scoped_sending_event.h" -@interface AtomApplication : NSApplication { +@interface AtomApplication : NSApplication { @private BOOL handlingSendEvent_; base::scoped_nsobject currentActivity_; diff --git a/atom/browser/mac/atom_application_delegate.h b/atom/browser/mac/atom_application_delegate.h index 777475213ec..835b63f8308 100644 --- a/atom/browser/mac/atom_application_delegate.h +++ b/atom/browser/mac/atom_application_delegate.h @@ -6,7 +6,7 @@ #import "atom/browser/ui/cocoa/atom_menu_controller.h" -@interface AtomApplicationDelegate : NSObject { +@interface AtomApplicationDelegate : NSObject { @private base::scoped_nsobject menu_controller_; } diff --git a/atom/browser/mac/in_app_purchase_observer.h b/atom/browser/mac/in_app_purchase_observer.h index d2d0be2b0ae..351db2008ef 100644 --- a/atom/browser/mac/in_app_purchase_observer.h +++ b/atom/browser/mac/in_app_purchase_observer.h @@ -13,7 +13,7 @@ #if defined(__OBJC__) @class InAppTransactionObserver; -#else // __OBJC__ +#else // __OBJC__ class InAppTransactionObserver; #endif // __OBJC__ diff --git a/atom/browser/native_browser_view.h b/atom/browser/native_browser_view.h index cab6980fa2c..56937e4c8c6 100644 --- a/atom/browser/native_browser_view.h +++ b/atom/browser/native_browser_view.h @@ -15,7 +15,7 @@ namespace brightray { class InspectableWebContents; class InspectableWebContentsView; -} +} // namespace brightray namespace gfx { class Rect; @@ -48,7 +48,7 @@ class NativeBrowserView { // Called when the window needs to update its draggable region. virtual void UpdateDraggableRegions( - const std::vector& system_drag_exclude_areas) {} + const std::vector& system_drag_exclude_areas) {} protected: explicit NativeBrowserView( diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 0a3db8cbf07..e3568007ca6 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -113,9 +113,9 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) { bool fullscreen = false; if (options.Get(options::kFullscreen, &fullscreen) && !fullscreen) { // Disable fullscreen button if 'fullscreen' is specified to false. - #if defined(OS_MACOSX) +#if defined(OS_MACOSX) fullscreenable = false; - #endif +#endif } // Overriden by 'fullscreenable'. options.Get(options::kFullScreenable, &fullscreenable); @@ -261,75 +261,59 @@ double NativeWindow::GetSheetOffsetY() { return sheet_offset_y_; } -void NativeWindow::SetRepresentedFilename(const std::string& filename) { -} +void NativeWindow::SetRepresentedFilename(const std::string& filename) {} std::string NativeWindow::GetRepresentedFilename() { return ""; } -void NativeWindow::SetDocumentEdited(bool edited) { -} +void NativeWindow::SetDocumentEdited(bool edited) {} bool NativeWindow::IsDocumentEdited() { return false; } -void NativeWindow::SetFocusable(bool focusable) { -} +void NativeWindow::SetFocusable(bool focusable) {} -void NativeWindow::SetMenu(AtomMenuModel* menu) { -} +void NativeWindow::SetMenu(AtomMenuModel* menu) {} void NativeWindow::SetParentWindow(NativeWindow* parent) { parent_ = parent; } -void NativeWindow::SetAutoHideCursor(bool auto_hide) { -} +void NativeWindow::SetAutoHideCursor(bool auto_hide) {} -void NativeWindow::SelectPreviousTab() { -} +void NativeWindow::SelectPreviousTab() {} -void NativeWindow::SelectNextTab() { -} +void NativeWindow::SelectNextTab() {} -void NativeWindow::MergeAllWindows() { -} +void NativeWindow::MergeAllWindows() {} -void NativeWindow::MoveTabToNewWindow() { -} +void NativeWindow::MoveTabToNewWindow() {} -void NativeWindow::ToggleTabBar() { -} +void NativeWindow::ToggleTabBar() {} bool NativeWindow::AddTabbedWindow(NativeWindow* window) { return true; // for non-Mac platforms } -void NativeWindow::SetVibrancy(const std::string& filename) { -} +void NativeWindow::SetVibrancy(const std::string& filename) {} void NativeWindow::SetTouchBar( - const std::vector& items) { -} + const std::vector& items) {} -void NativeWindow::RefreshTouchBarItem(const std::string& item_id) { -} +void NativeWindow::RefreshTouchBarItem(const std::string& item_id) {} void NativeWindow::SetEscapeTouchBarItem( - const mate::PersistentDictionary& item) { -} + const mate::PersistentDictionary& item) {} -void NativeWindow::SetAutoHideMenuBar(bool auto_hide) { -} +void NativeWindow::SetAutoHideMenuBar(bool auto_hide) {} bool NativeWindow::IsMenuBarAutoHide() { return false; } -void NativeWindow::SetMenuBarVisibility(bool visible) { -} +void NativeWindow::SetMenuBarVisibility(bool visible) {} bool NativeWindow::IsMenuBarVisible() { return true; @@ -350,11 +334,9 @@ void NativeWindow::SetAspectRatio(double aspect_ratio, } void NativeWindow::PreviewFile(const std::string& path, - const std::string& display_name) { -} + const std::string& display_name) {} -void NativeWindow::CloseFilePreview() { -} +void NativeWindow::CloseFilePreview() {} void NativeWindow::NotifyWindowRequestPreferredWith(int* width) { for (NativeWindowObserver& observer : observers_) @@ -510,13 +492,14 @@ void NativeWindow::NotifyTouchBarItemInteraction( } void NativeWindow::NotifyNewWindowForTab() { - for (NativeWindowObserver &observer : observers_) + for (NativeWindowObserver& observer : observers_) observer.OnNewWindowForTab(); } #if defined(OS_WIN) -void NativeWindow::NotifyWindowMessage( - UINT message, WPARAM w_param, LPARAM l_param) { +void NativeWindow::NotifyWindowMessage(UINT message, + WPARAM w_param, + LPARAM l_param) { for (NativeWindowObserver& observer : observers_) observer.OnWindowMessage(message, w_param, l_param); } diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 2131574dcce..f8729a7be5a 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -33,12 +33,12 @@ class Point; class Rect; class RectF; class Size; -} +} // namespace gfx namespace mate { class Dictionary; class PersistentDictionary; -} +} // namespace mate namespace atom { @@ -154,15 +154,14 @@ class NativeWindow : public base::SupportsUserData { // Taskbar/Dock APIs. enum ProgressState { - PROGRESS_NONE, // no progress, no marking - PROGRESS_INDETERMINATE, // progress, indeterminate - PROGRESS_ERROR, // progress, errored (red) - PROGRESS_PAUSED, // progress, paused (yellow) - PROGRESS_NORMAL, // progress, not marked (green) + PROGRESS_NONE, // no progress, no marking + PROGRESS_INDETERMINATE, // progress, indeterminate + PROGRESS_ERROR, // progress, errored (red) + PROGRESS_PAUSED, // progress, paused (yellow) + PROGRESS_NORMAL, // progress, not marked (green) }; - virtual void SetProgressBar(double progress, - const ProgressState state) = 0; + virtual void SetProgressBar(double progress, const ProgressState state) = 0; virtual void SetOverlayIcon(const gfx::Image& overlay, const std::string& description) = 0; @@ -251,13 +250,11 @@ class NativeWindow : public base::SupportsUserData { const base::DictionaryValue& details); void NotifyNewWindowForTab(); - #if defined(OS_WIN) +#if defined(OS_WIN) void NotifyWindowMessage(UINT message, WPARAM w_param, LPARAM l_param); - #endif +#endif - void AddObserver(NativeWindowObserver* obs) { - observers_.AddObserver(obs); - } + void AddObserver(NativeWindowObserver* obs) { observers_.AddObserver(obs); } void RemoveObserver(NativeWindowObserver* obs) { observers_.RemoveObserver(obs); } @@ -273,8 +270,7 @@ class NativeWindow : public base::SupportsUserData { bool is_modal() const { return is_modal_; } protected: - NativeWindow(const mate::Dictionary& options, - NativeWindow* parent); + NativeWindow(const mate::Dictionary& options, NativeWindow* parent); void set_browser_view(NativeBrowserView* browser_view) { browser_view_ = browser_view; @@ -324,11 +320,11 @@ class NativeWindow : public base::SupportsUserData { }; // This class provides a hook to get a NativeWindow from a WebContents. -class NativeWindowRelay : - public content::WebContentsUserData { +class NativeWindowRelay + : public content::WebContentsUserData { public: explicit NativeWindowRelay(base::WeakPtr window) - : key(UserDataKey()), window(window) {} + : key(UserDataKey()), window(window) {} static void* UserDataKey() { return content::WebContentsUserData::UserDataKey(); diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index 9e4edaa2c0c..562e04c844e 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -21,8 +21,7 @@ namespace atom { class NativeWindowMac : public NativeWindow { public: - NativeWindowMac(const mate::Dictionary& options, - NativeWindow* parent); + NativeWindowMac(const mate::Dictionary& options, NativeWindow* parent); ~NativeWindowMac() override; // NativeWindow: @@ -53,10 +52,10 @@ class NativeWindowMac : public NativeWindow { void MoveTop() override; bool IsResizable() override; void SetMovable(bool movable) override; - void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size) - override; - void PreviewFile(const std::string& path, const std::string& display_name) - override; + void SetAspectRatio(double aspect_ratio, + const gfx::Size& extra_size) override; + void PreviewFile(const std::string& path, + const std::string& display_name) override; void CloseFilePreview() override; bool IsMovable() override; void SetMinimizable(bool minimizable) override; @@ -67,8 +66,10 @@ class NativeWindowMac : public NativeWindow { bool IsFullScreenable() override; void SetClosable(bool closable) override; bool IsClosable() override; - void SetAlwaysOnTop(bool top, const std::string& level, - int relativeLevel, std::string* error) override; + void SetAlwaysOnTop(bool top, + const std::string& level, + int relativeLevel, + std::string* error) override; bool IsAlwaysOnTop() override; void Center() override; void Invalidate() override; diff --git a/atom/browser/native_window_observer.h b/atom/browser/native_window_observer.h index 4dfd3521091..33e9eb64325 100644 --- a/atom/browser/native_window_observer.h +++ b/atom/browser/native_window_observer.h @@ -79,10 +79,10 @@ class NativeWindowObserver { const base::DictionaryValue& details) {} virtual void OnNewWindowForTab() {} - // Called when window message received - #if defined(OS_WIN) +// Called when window message received +#if defined(OS_WIN) virtual void OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) {} - #endif +#endif // Called on Windows when App Commands arrive (WM_APPCOMMAND) virtual void OnExecuteWindowsCommand(const std::string& command_name) {} diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 6aa2dca3aff..0c81e7cea55 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -102,13 +102,12 @@ class NativeWindowClientView : public views::ClientView { public: NativeWindowClientView(views::Widget* widget, NativeWindowViews* contents_view) - : views::ClientView(widget, contents_view) { - } + : views::ClientView(widget, contents_view) {} virtual ~NativeWindowClientView() {} bool CanClose() override { - static_cast(contents_view())-> - NotifyWindowCloseButtonClicked(); + static_cast(contents_view()) + ->NotifyWindowCloseButtonClicked(); return false; } @@ -196,8 +195,7 @@ NativeWindowViews::NativeWindowViews(const mate::Dictionary& options, params.native_widget = new AtomDesktopNativeWidgetAura(window_.get()); atom_desktop_window_tree_host_win_ = new AtomDesktopWindowTreeHostWin( - this, - window_.get(), + this, window_.get(), static_cast(params.native_widget)); params.desktop_window_tree_host = atom_desktop_window_tree_host_win_; #elif defined(USE_X11) @@ -227,10 +225,9 @@ NativeWindowViews::NativeWindowViews(const mate::Dictionary& options, XDisplay* xdisplay = gfx::GetXDisplay(); XChangeProperty(xdisplay, GetAcceleratedWidget(), XInternAtom(xdisplay, "_GTK_THEME_VARIANT", False), - XInternAtom(xdisplay, "UTF8_STRING", False), - 8, PropModeReplace, - reinterpret_cast("dark"), - 4); + XInternAtom(xdisplay, "UTF8_STRING", False), 8, + PropModeReplace, + reinterpret_cast("dark"), 4); } // Before the window is mapped the SetWMSpecState can not work, so we have @@ -641,9 +638,9 @@ void NativeWindowViews::SetResizable(bool resizable) { void NativeWindowViews::MoveTop() { gfx::Point pos = GetPosition(); gfx::Size size = GetSize(); - ::SetWindowPos(GetAcceleratedWidget(), HWND_TOP, - pos.x(), pos.y(), size.width(), size.height(), - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); + ::SetWindowPos(GetAcceleratedWidget(), HWND_TOP, pos.x(), pos.y(), + size.width(), size.height(), + SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); } #endif @@ -735,8 +732,10 @@ bool NativeWindowViews::IsClosable() { #endif } -void NativeWindowViews::SetAlwaysOnTop(bool top, const std::string& level, - int relativeLevel, std::string* error) { +void NativeWindowViews::SetAlwaysOnTop(bool top, + const std::string& level, + int relativeLevel, + std::string* error) { window_->SetAlwaysOnTop(top); } @@ -820,24 +819,23 @@ void NativeWindowViews::SetBackgroundColor(SkColor background_color) { #if defined(OS_WIN) // Set the background color of native window. HBRUSH brush = CreateSolidBrush(skia::SkColorToCOLORREF(background_color)); - ULONG_PTR previous_brush = SetClassLongPtr( - GetAcceleratedWidget(), - GCLP_HBRBACKGROUND, - reinterpret_cast(brush)); + ULONG_PTR previous_brush = + SetClassLongPtr(GetAcceleratedWidget(), GCLP_HBRBACKGROUND, + reinterpret_cast(brush)); if (previous_brush) DeleteObject((HBRUSH)previous_brush); #endif } void NativeWindowViews::SetHasShadow(bool has_shadow) { - wm::SetShadowElevation( - GetNativeWindow(), - has_shadow ? wm::ShadowElevation::MEDIUM : wm::ShadowElevation::NONE); + wm::SetShadowElevation(GetNativeWindow(), has_shadow + ? wm::ShadowElevation::MEDIUM + : wm::ShadowElevation::NONE); } bool NativeWindowViews::HasShadow() { - return GetNativeWindow()->GetProperty(wm::kShadowElevationKey) - != wm::ShadowElevation::NONE; + return GetNativeWindow()->GetProperty(wm::kShadowElevationKey) != + wm::ShadowElevation::NONE; } void NativeWindowViews::SetOpacity(const double opacity) { @@ -881,8 +879,8 @@ void NativeWindowViews::SetIgnoreMouseEvents(bool ignore, bool forward) { XShapeCombineRectangles(gfx::GetXDisplay(), GetAcceleratedWidget(), ShapeInput, 0, 0, &r, 1, ShapeSet, YXBanded); } else { - XShapeCombineMask(gfx::GetXDisplay(), GetAcceleratedWidget(), - ShapeInput, 0, 0, None, ShapeSet); + XShapeCombineMask(gfx::GetXDisplay(), GetAcceleratedWidget(), ShapeInput, 0, + 0, None, ShapeSet); } #endif } @@ -997,7 +995,7 @@ void NativeWindowViews::SetParentWindow(NativeWindow* parent) { XDisplay* xdisplay = gfx::GetXDisplay(); XSetTransientForHint( xdisplay, GetAcceleratedWidget(), - parent? parent->GetAcceleratedWidget() : DefaultRootWindow(xdisplay)); + parent ? parent->GetAcceleratedWidget() : DefaultRootWindow(xdisplay)); #elif defined(OS_WIN) && defined(DEBUG) // Should work, but does not, it seems that the views toolkit doesn't support // reparenting on desktop. @@ -1024,8 +1022,8 @@ gfx::NativeWindow NativeWindowViews::GetNativeWindow() const { return window_->GetNativeWindow(); } -void NativeWindowViews::SetProgressBar( - double progress, NativeWindow::ProgressState state) { +void NativeWindowViews::SetProgressBar(double progress, + NativeWindow::ProgressState state) { #if defined(OS_WIN) taskbar_host_.SetProgressBar(GetAcceleratedWidget(), progress, state); #elif defined(USE_X11) @@ -1085,8 +1083,8 @@ bool NativeWindowViews::IsVisibleOnAllWorkspaces() { XAtom sticky_atom = GetAtom("_NET_WM_STATE_STICKY"); std::vector wm_states; ui::GetAtomArrayProperty(GetAcceleratedWidget(), "_NET_WM_STATE", &wm_states); - return std::find(wm_states.begin(), - wm_states.end(), sticky_atom) != wm_states.end(); + return std::find(wm_states.begin(), wm_states.end(), sticky_atom) != + wm_states.end(); #endif return false; } @@ -1165,21 +1163,21 @@ void NativeWindowViews::SetIcon(HICON window_icon, HICON app_icon) { void NativeWindowViews::SetIcon(const gfx::ImageSkia& icon) { views::DesktopWindowTreeHostX11* tree_host = views::DesktopWindowTreeHostX11::GetHostForXID(GetAcceleratedWidget()); - static_cast(tree_host)->SetWindowIcons( - icon, icon); + static_cast(tree_host)->SetWindowIcons(icon, + icon); } #endif -void NativeWindowViews::OnWidgetActivationChanged( - views::Widget* widget, bool active) { +void NativeWindowViews::OnWidgetActivationChanged(views::Widget* widget, + bool active) { if (widget != window_.get()) return; // Post the notification to next tick. content::BrowserThread::PostTask( content::BrowserThread::UI, FROM_HERE, - base::Bind(active ? &NativeWindow::NotifyWindowFocus : - &NativeWindow::NotifyWindowBlur, + base::Bind(active ? &NativeWindow::NotifyWindowFocus + : &NativeWindow::NotifyWindowBlur, GetWeakPtr())); // Hide menu bar when window is blured. @@ -1189,8 +1187,8 @@ void NativeWindowViews::OnWidgetActivationChanged( menu_bar_alt_pressed_ = false; } -void NativeWindowViews::OnWidgetBoundsChanged( - views::Widget* widget, const gfx::Rect& bounds) { +void NativeWindowViews::OnWidgetBoundsChanged(views::Widget* widget, + const gfx::Rect& bounds) { if (widget != window_.get()) return; @@ -1199,8 +1197,8 @@ void NativeWindowViews::OnWidgetBoundsChanged( const auto new_bounds = GetBounds(); if (widget_size_ != new_bounds.size()) { if (browser_view()) { - const auto flags = static_cast(browser_view())-> - GetAutoResizeFlags(); + const auto flags = static_cast(browser_view()) + ->GetAutoResizeFlags(); int width_delta = 0; int height_delta = 0; if (flags & kAutoResizeWidth) { @@ -1285,8 +1283,8 @@ bool NativeWindowViews::ShouldDescendIntoChildForEventHandling( // And the events on border for dragging resizable frameless window. if (!has_frame() && CanResize()) { - FramelessView* frame = static_cast( - window_->non_client_view()->frame_view()); + FramelessView* frame = + static_cast(window_->non_client_view()->frame_view()); return frame->ResizingBorderHitTest(location) == HTNOWHERE; } @@ -1328,8 +1326,8 @@ void NativeWindowViews::HandleKeyboardEvent( // Show accelerator when "Alt" is pressed. if (menu_bar_visible_ && IsAltKey(event)) - menu_bar_->SetAcceleratorVisibility( - event.GetType() == blink::WebInputEvent::kRawKeyDown); + menu_bar_->SetAcceleratorVisibility(event.GetType() == + blink::WebInputEvent::kRawKeyDown); // Show the submenu when "Alt+Key" is pressed. if (event.GetType() == blink::WebInputEvent::kRawKeyDown && @@ -1385,8 +1383,8 @@ gfx::Size NativeWindowViews::GetMaximumSize() const { } bool NativeWindowViews::AcceleratorPressed(const ui::Accelerator& accelerator) { - return accelerator_util::TriggerAcceleratorTableCommand( - &accelerator_table_, accelerator); + return accelerator_util::TriggerAcceleratorTableCommand(&accelerator_table_, + accelerator); } void NativeWindowViews::RegisterAccelerators(AtomMenuModel* menu_model) { diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index dfb9016af97..4a71e70eac8 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -19,8 +19,6 @@ #include "atom/browser/ui/win/message_handler_delegate.h" #include "atom/browser/ui/win/taskbar_host.h" #include "base/win/scoped_gdi_object.h" -#include "ui/base/win/accessibility_misc_utils.h" -#include #endif namespace views { @@ -46,8 +44,7 @@ class NativeWindowViews : public NativeWindow, public views::WidgetDelegateView, public views::WidgetObserver { public: - NativeWindowViews(const mate::Dictionary& options, - NativeWindow* parent); + NativeWindowViews(const mate::Dictionary& options, NativeWindow* parent); ~NativeWindowViews() override; // NativeWindow: @@ -91,8 +88,10 @@ class NativeWindowViews : public NativeWindow, bool IsFullScreenable() override; void SetClosable(bool closable) override; bool IsClosable() override; - void SetAlwaysOnTop(bool top, const std::string& level, - int relativeLevel, std::string* error) override; + void SetAlwaysOnTop(bool top, + const std::string& level, + int relativeLevel, + std::string* error) override; bool IsAlwaysOnTop() override; void Center() override; void Invalidate() override; @@ -150,10 +149,9 @@ class NativeWindowViews : public NativeWindow, private: // views::WidgetObserver: - void OnWidgetActivationChanged( - views::Widget* widget, bool active) override; - void OnWidgetBoundsChanged( - views::Widget* widget, const gfx::Rect& bounds) override; + void OnWidgetActivationChanged(views::Widget* widget, bool active) override; + void OnWidgetBoundsChanged(views::Widget* widget, + const gfx::Rect& bounds) override; // views::WidgetDelegate: void DeleteDelegate() override; @@ -167,8 +165,8 @@ class NativeWindowViews : public NativeWindow, const views::Widget* GetWidget() const override; views::View* GetContentsView() override; bool ShouldDescendIntoChildForEventHandling( - gfx::NativeView child, - const gfx::Point& location) override; + gfx::NativeView child, + const gfx::Point& location) override; views::ClientView* CreateClientView(views::Widget* widget) override; views::NonClientFrameView* CreateNonClientFrameView( views::Widget* widget) override; @@ -179,15 +177,21 @@ class NativeWindowViews : public NativeWindow, #if defined(OS_WIN) // MessageHandlerDelegate: - bool PreHandleMSG( - UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) override; + bool PreHandleMSG(UINT message, + WPARAM w_param, + LPARAM l_param, + LRESULT* result) override; void HandleSizeEvent(WPARAM w_param, LPARAM l_param); void SetForwardMouseMessages(bool forward); - static LRESULT CALLBACK SubclassProc( - HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param, UINT_PTR subclass_id, - DWORD_PTR ref_data); - static LRESULT CALLBACK MouseHookProc( - int n_code, WPARAM w_param, LPARAM l_param); + static LRESULT CALLBACK SubclassProc(HWND hwnd, + UINT msg, + WPARAM w_param, + LPARAM l_param, + UINT_PTR subclass_id, + DWORD_PTR ref_data); + static LRESULT CALLBACK MouseHookProc(int n_code, + WPARAM w_param, + LPARAM l_param); #endif // NativeWindow: diff --git a/atom/browser/native_window_views_win.cc b/atom/browser/native_window_views_win.cc index 746a9978b8f..86e65baf049 100644 --- a/atom/browser/native_window_views_win.cc +++ b/atom/browser/native_window_views_win.cc @@ -5,6 +5,10 @@ #include "atom/browser/browser.h" #include "atom/browser/native_window_views.h" #include "content/public/browser/browser_accessibility_state.h" +#include "ui/base/win/accessibility_misc_utils.h" + +// Must be included after other Windows headers. +#include namespace atom { @@ -13,58 +17,110 @@ namespace { // Convert Win32 WM_APPCOMMANDS to strings. const char* AppCommandToString(int command_id) { switch (command_id) { - case APPCOMMAND_BROWSER_BACKWARD : return "browser-backward"; - case APPCOMMAND_BROWSER_FORWARD : return "browser-forward"; - case APPCOMMAND_BROWSER_REFRESH : return "browser-refresh"; - case APPCOMMAND_BROWSER_STOP : return "browser-stop"; - case APPCOMMAND_BROWSER_SEARCH : return "browser-search"; - case APPCOMMAND_BROWSER_FAVORITES : return "browser-favorites"; - case APPCOMMAND_BROWSER_HOME : return "browser-home"; - case APPCOMMAND_VOLUME_MUTE : return "volume-mute"; - case APPCOMMAND_VOLUME_DOWN : return "volume-down"; - case APPCOMMAND_VOLUME_UP : return "volume-up"; - case APPCOMMAND_MEDIA_NEXTTRACK : return "media-nexttrack"; - case APPCOMMAND_MEDIA_PREVIOUSTRACK : return "media-previoustrack"; - case APPCOMMAND_MEDIA_STOP : return "media-stop"; - case APPCOMMAND_MEDIA_PLAY_PAUSE : return "media-play_pause"; - case APPCOMMAND_LAUNCH_MAIL : return "launch-mail"; - case APPCOMMAND_LAUNCH_MEDIA_SELECT : return "launch-media-select"; - case APPCOMMAND_LAUNCH_APP1 : return "launch-app1"; - case APPCOMMAND_LAUNCH_APP2 : return "launch-app2"; - case APPCOMMAND_BASS_DOWN : return "bass-down"; - case APPCOMMAND_BASS_BOOST : return "bass-boost"; - case APPCOMMAND_BASS_UP : return "bass-up"; - case APPCOMMAND_TREBLE_DOWN : return "treble-down"; - case APPCOMMAND_TREBLE_UP : return "treble-up"; - case APPCOMMAND_MICROPHONE_VOLUME_MUTE : return "microphone-volume-mute"; - case APPCOMMAND_MICROPHONE_VOLUME_DOWN : return "microphone-volume-down"; - case APPCOMMAND_MICROPHONE_VOLUME_UP : return "microphone-volume-up"; - case APPCOMMAND_HELP : return "help"; - case APPCOMMAND_FIND : return "find"; - case APPCOMMAND_NEW : return "new"; - case APPCOMMAND_OPEN : return "open"; - case APPCOMMAND_CLOSE : return "close"; - case APPCOMMAND_SAVE : return "save"; - case APPCOMMAND_PRINT : return "print"; - case APPCOMMAND_UNDO : return "undo"; - case APPCOMMAND_REDO : return "redo"; - case APPCOMMAND_COPY : return "copy"; - case APPCOMMAND_CUT : return "cut"; - case APPCOMMAND_PASTE : return "paste"; - case APPCOMMAND_REPLY_TO_MAIL : return "reply-to-mail"; - case APPCOMMAND_FORWARD_MAIL : return "forward-mail"; - case APPCOMMAND_SEND_MAIL : return "send-mail"; - case APPCOMMAND_SPELL_CHECK : return "spell-check"; - case APPCOMMAND_MIC_ON_OFF_TOGGLE : return "mic-on-off-toggle"; - case APPCOMMAND_CORRECTION_LIST : return "correction-list"; - case APPCOMMAND_MEDIA_PLAY : return "media-play"; - case APPCOMMAND_MEDIA_PAUSE : return "media-pause"; - case APPCOMMAND_MEDIA_RECORD : return "media-record"; - case APPCOMMAND_MEDIA_FAST_FORWARD : return "media-fast-forward"; - case APPCOMMAND_MEDIA_REWIND : return "media-rewind"; - case APPCOMMAND_MEDIA_CHANNEL_UP : return "media-channel-up"; - case APPCOMMAND_MEDIA_CHANNEL_DOWN : return "media-channel-down"; - case APPCOMMAND_DELETE : return "delete"; + case APPCOMMAND_BROWSER_BACKWARD: + return "browser-backward"; + case APPCOMMAND_BROWSER_FORWARD: + return "browser-forward"; + case APPCOMMAND_BROWSER_REFRESH: + return "browser-refresh"; + case APPCOMMAND_BROWSER_STOP: + return "browser-stop"; + case APPCOMMAND_BROWSER_SEARCH: + return "browser-search"; + case APPCOMMAND_BROWSER_FAVORITES: + return "browser-favorites"; + case APPCOMMAND_BROWSER_HOME: + return "browser-home"; + case APPCOMMAND_VOLUME_MUTE: + return "volume-mute"; + case APPCOMMAND_VOLUME_DOWN: + return "volume-down"; + case APPCOMMAND_VOLUME_UP: + return "volume-up"; + case APPCOMMAND_MEDIA_NEXTTRACK: + return "media-nexttrack"; + case APPCOMMAND_MEDIA_PREVIOUSTRACK: + return "media-previoustrack"; + case APPCOMMAND_MEDIA_STOP: + return "media-stop"; + case APPCOMMAND_MEDIA_PLAY_PAUSE: + return "media-play_pause"; + case APPCOMMAND_LAUNCH_MAIL: + return "launch-mail"; + case APPCOMMAND_LAUNCH_MEDIA_SELECT: + return "launch-media-select"; + case APPCOMMAND_LAUNCH_APP1: + return "launch-app1"; + case APPCOMMAND_LAUNCH_APP2: + return "launch-app2"; + case APPCOMMAND_BASS_DOWN: + return "bass-down"; + case APPCOMMAND_BASS_BOOST: + return "bass-boost"; + case APPCOMMAND_BASS_UP: + return "bass-up"; + case APPCOMMAND_TREBLE_DOWN: + return "treble-down"; + case APPCOMMAND_TREBLE_UP: + return "treble-up"; + case APPCOMMAND_MICROPHONE_VOLUME_MUTE: + return "microphone-volume-mute"; + case APPCOMMAND_MICROPHONE_VOLUME_DOWN: + return "microphone-volume-down"; + case APPCOMMAND_MICROPHONE_VOLUME_UP: + return "microphone-volume-up"; + case APPCOMMAND_HELP: + return "help"; + case APPCOMMAND_FIND: + return "find"; + case APPCOMMAND_NEW: + return "new"; + case APPCOMMAND_OPEN: + return "open"; + case APPCOMMAND_CLOSE: + return "close"; + case APPCOMMAND_SAVE: + return "save"; + case APPCOMMAND_PRINT: + return "print"; + case APPCOMMAND_UNDO: + return "undo"; + case APPCOMMAND_REDO: + return "redo"; + case APPCOMMAND_COPY: + return "copy"; + case APPCOMMAND_CUT: + return "cut"; + case APPCOMMAND_PASTE: + return "paste"; + case APPCOMMAND_REPLY_TO_MAIL: + return "reply-to-mail"; + case APPCOMMAND_FORWARD_MAIL: + return "forward-mail"; + case APPCOMMAND_SEND_MAIL: + return "send-mail"; + case APPCOMMAND_SPELL_CHECK: + return "spell-check"; + case APPCOMMAND_MIC_ON_OFF_TOGGLE: + return "mic-on-off-toggle"; + case APPCOMMAND_CORRECTION_LIST: + return "correction-list"; + case APPCOMMAND_MEDIA_PLAY: + return "media-play"; + case APPCOMMAND_MEDIA_PAUSE: + return "media-pause"; + case APPCOMMAND_MEDIA_RECORD: + return "media-record"; + case APPCOMMAND_MEDIA_FAST_FORWARD: + return "media-fast-forward"; + case APPCOMMAND_MEDIA_REWIND: + return "media-rewind"; + case APPCOMMAND_MEDIA_CHANNEL_UP: + return "media-channel-up"; + case APPCOMMAND_MEDIA_CHANNEL_DOWN: + return "media-channel-down"; + case APPCOMMAND_DELETE: + return "delete"; case APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE: return "dictate-or-command-control-toggle"; default: @@ -89,8 +145,10 @@ bool NativeWindowViews::ExecuteWindowsCommand(int command_id) { return false; } -bool NativeWindowViews::PreHandleMSG( - UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) { +bool NativeWindowViews::PreHandleMSG(UINT message, + WPARAM w_param, + LPARAM l_param, + LRESULT* result) { NotifyWindowMessage(message, w_param, l_param); switch (message) { @@ -100,7 +158,8 @@ bool NativeWindowViews::PreHandleMSG( // because we still want Chromium to handle returning the actual // accessibility object. case WM_GETOBJECT: { - if (checked_for_a11y_support_) return false; + if (checked_for_a11y_support_) + return false; const DWORD obj_id = static_cast(l_param); @@ -231,8 +290,8 @@ void NativeWindowViews::SetForwardMouseMessages(bool forward) { // Subclassing is used to fix some issues when forwarding mouse messages; // see comments in |SubclassProc|. - SetWindowSubclass( - legacy_window_, SubclassProc, 1, reinterpret_cast(this)); + SetWindowSubclass(legacy_window_, SubclassProc, 1, + reinterpret_cast(this)); if (!mouse_hook_) { mouse_hook_ = SetWindowsHookEx(WH_MOUSE_LL, MouseHookProc, NULL, 0); @@ -250,9 +309,12 @@ void NativeWindowViews::SetForwardMouseMessages(bool forward) { } } -LRESULT CALLBACK NativeWindowViews::SubclassProc( - HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param, UINT_PTR subclass_id, - DWORD_PTR ref_data) { +LRESULT CALLBACK NativeWindowViews::SubclassProc(HWND hwnd, + UINT msg, + WPARAM w_param, + LPARAM l_param, + UINT_PTR subclass_id, + DWORD_PTR ref_data) { NativeWindowViews* window = reinterpret_cast(ref_data); switch (msg) { case WM_MOUSELEAVE: { @@ -276,8 +338,9 @@ LRESULT CALLBACK NativeWindowViews::SubclassProc( return DefSubclassProc(hwnd, msg, w_param, l_param); } -LRESULT CALLBACK NativeWindowViews::MouseHookProc( - int n_code, WPARAM w_param, LPARAM l_param) { +LRESULT CALLBACK NativeWindowViews::MouseHookProc(int n_code, + WPARAM w_param, + LPARAM l_param) { if (n_code < 0) { return CallNextHookEx(NULL, n_code, w_param, l_param); } diff --git a/atom/browser/net/asar/asar_protocol_handler.cc b/atom/browser/net/asar/asar_protocol_handler.cc index ffa2b3c9f28..c2f53fa9d10 100644 --- a/atom/browser/net/asar/asar_protocol_handler.cc +++ b/atom/browser/net/asar/asar_protocol_handler.cc @@ -14,8 +14,7 @@ AsarProtocolHandler::AsarProtocolHandler( const scoped_refptr& file_task_runner) : file_task_runner_(file_task_runner) {} -AsarProtocolHandler::~AsarProtocolHandler() { -} +AsarProtocolHandler::~AsarProtocolHandler() {} net::URLRequestJob* AsarProtocolHandler::MaybeCreateJob( net::URLRequest* request, diff --git a/atom/browser/net/asar/url_request_asar_job.cc b/atom/browser/net/asar/url_request_asar_job.cc index ebbc65ec8d8..b86c67f095a 100644 --- a/atom/browser/net/asar/url_request_asar_job.cc +++ b/atom/browser/net/asar/url_request_asar_job.cc @@ -36,12 +36,10 @@ URLRequestAsarJob::FileMetaInfo::FileMetaInfo() : file_size(0), mime_type_result(false), file_exists(false), - is_directory(false) { -} + is_directory(false) {} -URLRequestAsarJob::URLRequestAsarJob( - net::URLRequest* request, - net::NetworkDelegate* network_delegate) +URLRequestAsarJob::URLRequestAsarJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate) : net::URLRequestJob(request, network_delegate), type_(TYPE_ERROR), remaining_bytes_(0), @@ -118,8 +116,7 @@ void URLRequestAsarJob::Start() { } else { base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, - base::Bind(&URLRequestAsarJob::DidOpen, - weak_ptr_factory_.GetWeakPtr(), + base::Bind(&URLRequestAsarJob::DidOpen, weak_ptr_factory_.GetWeakPtr(), net::ERR_FILE_NOT_FOUND)); } } @@ -140,11 +137,10 @@ int URLRequestAsarJob::ReadRawData(net::IOBuffer* dest, int dest_size) { if (!dest_size) return 0; - int rv = stream_->Read(dest, - dest_size, - base::Bind(&URLRequestAsarJob::DidRead, - weak_ptr_factory_.GetWeakPtr(), - WrapRefCounted(dest))); + int rv = stream_->Read( + dest, dest_size, + base::Bind(&URLRequestAsarJob::DidRead, weak_ptr_factory_.GetWeakPtr(), + WrapRefCounted(dest))); if (rv >= 0) { remaining_bytes_ -= rv; DCHECK_GE(remaining_bytes_, 0); @@ -184,9 +180,9 @@ std::unique_ptr URLRequestAsarJob::SetUpSourceStream() { net::URLRequestJob::SetUpSourceStream(); // Bug 9936 - .svgz files needs to be decompressed. return base::LowerCaseEqualsASCII(file_path_.Extension(), ".svgz") - ? net::GzipSourceStream::Create(std::move(source), - net::SourceStream::TYPE_GZIP) - : std::move(source); + ? net::GzipSourceStream::Create(std::move(source), + net::SourceStream::TYPE_GZIP) + : std::move(source); } bool URLRequestAsarJob::GetMimeType(std::string* mime_type) const { @@ -265,9 +261,8 @@ void URLRequestAsarJob::DidFetchMetaInfo(const FileMetaInfo* meta_info) { return; } - int flags = base::File::FLAG_OPEN | - base::File::FLAG_READ | - base::File::FLAG_ASYNC; + int flags = + base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_ASYNC; int rv = stream_->Open( meta_info_.file_path, flags, base::Bind(&URLRequestAsarJob::DidOpen, weak_ptr_factory_.GetWeakPtr())); @@ -277,8 +272,8 @@ void URLRequestAsarJob::DidFetchMetaInfo(const FileMetaInfo* meta_info) { void URLRequestAsarJob::DidOpen(int result) { if (result != net::OK) { - NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED, - result)); + NotifyStartError( + net::URLRequestStatus(net::URLRequestStatus::FAILED, result)); return; } @@ -298,20 +293,19 @@ void URLRequestAsarJob::DidOpen(int result) { } if (!byte_range_.ComputeBounds(file_size)) { - NotifyStartError( - net::URLRequestStatus(net::URLRequestStatus::FAILED, - net::ERR_REQUEST_RANGE_NOT_SATISFIABLE)); + NotifyStartError(net::URLRequestStatus( + net::URLRequestStatus::FAILED, net::ERR_REQUEST_RANGE_NOT_SATISFIABLE)); return; } - remaining_bytes_ = byte_range_.last_byte_position() - - byte_range_.first_byte_position() + 1; + remaining_bytes_ = + byte_range_.last_byte_position() - byte_range_.first_byte_position() + 1; seek_offset_ = byte_range_.first_byte_position() + read_offset; if (remaining_bytes_ > 0 && seek_offset_ != 0) { - int rv = stream_->Seek(seek_offset_, - base::Bind(&URLRequestAsarJob::DidSeek, - weak_ptr_factory_.GetWeakPtr())); + int rv = + stream_->Seek(seek_offset_, base::Bind(&URLRequestAsarJob::DidSeek, + weak_ptr_factory_.GetWeakPtr())); if (rv != net::ERR_IO_PENDING) { // stream_->Seek() failed, so pass an intentionally erroneous value // into DidSeek(). @@ -327,9 +321,8 @@ void URLRequestAsarJob::DidOpen(int result) { void URLRequestAsarJob::DidSeek(int64_t result) { if (result != seek_offset_) { - NotifyStartError( - net::URLRequestStatus(net::URLRequestStatus::FAILED, - net::ERR_REQUEST_RANGE_NOT_SATISFIABLE)); + NotifyStartError(net::URLRequestStatus( + net::URLRequestStatus::FAILED, net::ERR_REQUEST_RANGE_NOT_SATISFIABLE)); return; } set_expected_content_size(remaining_bytes_); diff --git a/atom/browser/net/atom_cert_verifier.cc b/atom/browser/net/atom_cert_verifier.cc index 1a99f56829d..d2f3c15760d 100644 --- a/atom/browser/net/atom_cert_verifier.cc +++ b/atom/browser/net/atom_cert_verifier.cc @@ -75,8 +75,7 @@ class CertVerifierRequest : public AtomCertVerifier::Request { delete response; } - void Start(net::CRLSet* crl_set, - const net::NetLogWithSource& net_log) { + void Start(net::CRLSet* crl_set, const net::NetLogWithSource& net_log) { int error = cert_verifier_->default_verifier()->Verify( params_, crl_set, &result_, base::Bind(&CertVerifierRequest::OnDefaultVerificationDone, @@ -158,13 +157,12 @@ void AtomCertVerifier::SetVerifyProc(const VerifyProc& proc) { verify_proc_ = proc; } -int AtomCertVerifier::Verify( - const RequestParams& params, - net::CRLSet* crl_set, - net::CertVerifyResult* verify_result, - const net::CompletionCallback& callback, - std::unique_ptr* out_req, - const net::NetLogWithSource& net_log) { +int AtomCertVerifier::Verify(const RequestParams& params, + net::CRLSet* crl_set, + net::CertVerifyResult* verify_result, + const net::CompletionCallback& callback, + std::unique_ptr* out_req, + const net::NetLogWithSource& net_log) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (verify_proc_.is_null()) { diff --git a/atom/browser/net/atom_cert_verifier.h b/atom/browser/net/atom_cert_verifier.h index b95cfa8f6d9..78a212d0eaa 100644 --- a/atom/browser/net/atom_cert_verifier.h +++ b/atom/browser/net/atom_cert_verifier.h @@ -68,6 +68,6 @@ class AtomCertVerifier : public net::CertVerifier { DISALLOW_COPY_AND_ASSIGN(AtomCertVerifier); }; -} // namespace atom +} // namespace atom #endif // ATOM_BROWSER_NET_ATOM_CERT_VERIFIER_H_ diff --git a/atom/browser/net/atom_network_delegate.cc b/atom/browser/net/atom_network_delegate.cc index fe4424af5fa..79f1f480bd4 100644 --- a/atom/browser/net/atom_network_delegate.cc +++ b/atom/browser/net/atom_network_delegate.cc @@ -15,8 +15,8 @@ #include "content/public/browser/render_frame_host.h" #include "net/url_request/url_request.h" -using content::DevToolsNetworkTransaction; using content::BrowserThread; +using content::DevToolsNetworkTransaction; namespace atom { @@ -97,7 +97,7 @@ void ToDictionary(base::DictionaryValue* details, net::URLRequest* request) { const auto* info = content::ResourceRequestInfo::ForRequest(request); if (info) { details->SetString("resourceType", - ResourceTypeToString(info->GetResourceType())); + ResourceTypeToString(info->GetResourceType())); } else { details->SetString("resourceType", "other"); } @@ -157,12 +157,12 @@ void ToDictionary(base::DictionaryValue* details, } // Helper function to fill |details| with arbitrary |args|. -template +template void FillDetailsObject(base::DictionaryValue* details, Arg arg) { ToDictionary(details, arg); } -template +template void FillDetailsObject(base::DictionaryValue* details, Arg arg, Args... args) { ToDictionary(details, arg); FillDetailsObject(details, args...); @@ -181,8 +181,7 @@ void ReadFromResponseObject(const base::DictionaryValue& response, const base::DictionaryValue* dict; if (response.GetDictionary("requestHeaders", &dict)) { headers->Clear(); - for (base::DictionaryValue::Iterator it(*dict); - !it.IsAtEnd(); + for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { std::string value; if (it.value().GetAsString(&value)) @@ -201,8 +200,7 @@ void ReadFromResponseObject(const base::DictionaryValue& response, auto headers = container.first; *headers = new net::HttpResponseHeaders(""); (*headers)->ReplaceStatusLine(status_line); - for (base::DictionaryValue::Iterator it(*dict); - !it.IsAtEnd(); + for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { const base::ListValue* list; if (it.value().GetAsList(&list)) { @@ -219,30 +217,26 @@ void ReadFromResponseObject(const base::DictionaryValue& response, } // namespace -AtomNetworkDelegate::AtomNetworkDelegate() { -} +AtomNetworkDelegate::AtomNetworkDelegate() {} -AtomNetworkDelegate::~AtomNetworkDelegate() { -} +AtomNetworkDelegate::~AtomNetworkDelegate() {} -void AtomNetworkDelegate::SetSimpleListenerInIO( - SimpleEvent type, - URLPatterns patterns, - SimpleListener callback) { +void AtomNetworkDelegate::SetSimpleListenerInIO(SimpleEvent type, + URLPatterns patterns, + SimpleListener callback) { if (callback.is_null()) simple_listeners_.erase(type); else - simple_listeners_[type] = { std::move(patterns), std::move(callback) }; + simple_listeners_[type] = {std::move(patterns), std::move(callback)}; } -void AtomNetworkDelegate::SetResponseListenerInIO( - ResponseEvent type, - URLPatterns patterns, - ResponseListener callback) { +void AtomNetworkDelegate::SetResponseListenerInIO(ResponseEvent type, + URLPatterns patterns, + ResponseListener callback) { if (callback.is_null()) response_listeners_.erase(type); else - response_listeners_[type] = { std::move(patterns), std::move(callback) }; + response_listeners_[type] = {std::move(patterns), std::move(callback)}; } void AtomNetworkDelegate::SetDevToolsNetworkEmulationClientId( @@ -255,8 +249,8 @@ int AtomNetworkDelegate::OnBeforeURLRequest( const net::CompletionCallback& callback, GURL* new_url) { if (!base::ContainsKey(response_listeners_, kOnBeforeRequest)) - return brightray::NetworkDelegate::OnBeforeURLRequest( - request, callback, new_url); + return brightray::NetworkDelegate::OnBeforeURLRequest(request, callback, + new_url); return HandleResponseEvent(kOnBeforeRequest, request, callback, new_url); } @@ -273,8 +267,8 @@ int AtomNetworkDelegate::OnBeforeStartTransaction( return brightray::NetworkDelegate::OnBeforeStartTransaction( request, callback, headers); - return HandleResponseEvent( - kOnBeforeSendHeaders, request, callback, headers, *headers); + return HandleResponseEvent(kOnBeforeSendHeaders, request, callback, headers, + *headers); } void AtomNetworkDelegate::OnStartTransaction( @@ -358,8 +352,8 @@ void AtomNetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) { callbacks_.erase(request->identifier()); } -void AtomNetworkDelegate::OnErrorOccurred( - net::URLRequest* request, bool started) { +void AtomNetworkDelegate::OnErrorOccurred(net::URLRequest* request, + bool started) { if (!base::ContainsKey(simple_listeners_, kOnErrorOccurred)) { brightray::NetworkDelegate::OnCompleted(request, started); return; @@ -369,7 +363,7 @@ void AtomNetworkDelegate::OnErrorOccurred( request->status()); } -template +template int AtomNetworkDelegate::HandleResponseEvent( ResponseEvent type, net::URLRequest* request, @@ -400,9 +394,10 @@ int AtomNetworkDelegate::HandleResponseEvent( return net::ERR_IO_PENDING; } -template -void AtomNetworkDelegate::HandleSimpleEvent( - SimpleEvent type, net::URLRequest* request, Args... args) { +template +void AtomNetworkDelegate::HandleSimpleEvent(SimpleEvent type, + net::URLRequest* request, + Args... args) { const auto& info = simple_listeners_[type]; if (!MatchesFilterCondition(request, info.url_patterns)) return; @@ -420,9 +415,11 @@ void AtomNetworkDelegate::HandleSimpleEvent( render_process_id, render_frame_id)); } -template +template void AtomNetworkDelegate::OnListenerResultInIO( - uint64_t id, T out, std::unique_ptr response) { + uint64_t id, + T out, + std::unique_ptr response) { // The request has been destroyed. if (!base::ContainsKey(callbacks_, id)) return; @@ -434,14 +431,16 @@ void AtomNetworkDelegate::OnListenerResultInIO( callbacks_[id].Run(cancel ? net::ERR_BLOCKED_BY_CLIENT : net::OK); } -template +template void AtomNetworkDelegate::OnListenerResultInUI( - uint64_t id, T out, const base::DictionaryValue& response) { + uint64_t id, + T out, + const base::DictionaryValue& response) { std::unique_ptr copy = response.CreateDeepCopy(); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&AtomNetworkDelegate::OnListenerResultInIO, - base::Unretained(this), id, out, base::Passed(©))); + base::Unretained(this), id, out, base::Passed(©))); } } // namespace atom diff --git a/atom/browser/net/atom_network_delegate.h b/atom/browser/net/atom_network_delegate.h index ad37a926d47..8c6de3d4fe6 100644 --- a/atom/browser/net/atom_network_delegate.h +++ b/atom/browser/net/atom_network_delegate.h @@ -95,11 +95,11 @@ class AtomNetworkDelegate : public brightray::NetworkDelegate { private: void OnErrorOccurred(net::URLRequest* request, bool started); - template + template void HandleSimpleEvent(SimpleEvent type, net::URLRequest* request, Args... args); - template + template int HandleResponseEvent(ResponseEvent type, net::URLRequest* request, const net::CompletionCallback& callback, @@ -107,12 +107,14 @@ class AtomNetworkDelegate : public brightray::NetworkDelegate { Args... args); // Deal with the results of Listener. - template - void OnListenerResultInIO( - uint64_t id, T out, std::unique_ptr response); - template - void OnListenerResultInUI( - uint64_t id, T out, const base::DictionaryValue& response); + template + void OnListenerResultInIO(uint64_t id, + T out, + std::unique_ptr response); + template + void OnListenerResultInUI(uint64_t id, + T out, + const base::DictionaryValue& response); std::map simple_listeners_; std::map response_listeners_; @@ -124,6 +126,6 @@ class AtomNetworkDelegate : public brightray::NetworkDelegate { DISALLOW_COPY_AND_ASSIGN(AtomNetworkDelegate); }; -} // namespace atom +} // namespace atom #endif // ATOM_BROWSER_NET_ATOM_NETWORK_DELEGATE_H_ diff --git a/atom/browser/net/atom_url_request_job_factory.cc b/atom/browser/net/atom_url_request_job_factory.cc index 60676d3d8af..7047f7a6f7f 100644 --- a/atom/browser/net/atom_url_request_job_factory.cc +++ b/atom/browser/net/atom_url_request_job_factory.cc @@ -127,7 +127,7 @@ bool AtomURLRequestJobFactory::IsHandledProtocol( DCHECK_CURRENTLY_ON(BrowserThread::IO); return HasProtocolHandler(scheme) || - net::URLRequest::IsHandledProtocol(scheme); + net::URLRequest::IsHandledProtocol(scheme); } bool AtomURLRequestJobFactory::IsSafeRedirectTarget( diff --git a/atom/browser/net/atom_url_request_job_factory.h b/atom/browser/net/atom_url_request_job_factory.h index a560839b68e..97f08fa154f 100644 --- a/atom/browser/net/atom_url_request_job_factory.h +++ b/atom/browser/net/atom_url_request_job_factory.h @@ -30,9 +30,8 @@ class AtomURLRequestJobFactory : public net::URLRequestJobFactory { std::unique_ptr protocol_handler); // Intercepts the ProtocolHandler for a scheme. - bool InterceptProtocol( - const std::string& scheme, - std::unique_ptr protocol_handler); + bool InterceptProtocol(const std::string& scheme, + std::unique_ptr protocol_handler); bool UninterceptProtocol(const std::string& scheme); // Returns the protocol handler registered with scheme. @@ -65,8 +64,8 @@ class AtomURLRequestJobFactory : public net::URLRequestJobFactory { ProtocolHandlerMap protocol_handler_map_; // Map that stores the original protocols of schemes. - using OriginalProtocolsMap = std::unordered_map< - std::string, std::unique_ptr>; + using OriginalProtocolsMap = + std::unordered_map>; // Can only be accessed in IO thread. OriginalProtocolsMap original_protocols_; diff --git a/atom/browser/net/http_protocol_handler.cc b/atom/browser/net/http_protocol_handler.cc index cf5fc01c088..7c5cc365b74 100644 --- a/atom/browser/net/http_protocol_handler.cc +++ b/atom/browser/net/http_protocol_handler.cc @@ -9,18 +9,14 @@ namespace atom { HttpProtocolHandler::HttpProtocolHandler(const std::string& scheme) - : scheme_(scheme) { -} + : scheme_(scheme) {} -HttpProtocolHandler::~HttpProtocolHandler() { -} +HttpProtocolHandler::~HttpProtocolHandler() {} net::URLRequestJob* HttpProtocolHandler::MaybeCreateJob( net::URLRequest* request, net::NetworkDelegate* network_delegate) const { - return net::URLRequestHttpJob::Factory(request, - network_delegate, - scheme_); + return net::URLRequestHttpJob::Factory(request, network_delegate, scheme_); } } // namespace atom diff --git a/atom/browser/net/js_asker.cc b/atom/browser/net/js_asker.cc index 0df6bb5c37d..5d6f97b948a 100644 --- a/atom/browser/net/js_asker.cc +++ b/atom/browser/net/js_asker.cc @@ -22,9 +22,8 @@ void HandlerCallback(const BeforeStartCallback& before_start, // If there is no argument passed then we failed. v8::Local value; if (!args->GetNext(&value)) { - content::BrowserThread::PostTask( - content::BrowserThread::IO, FROM_HERE, - base::Bind(callback, false, nullptr)); + content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, + base::Bind(callback, false, nullptr)); return; } @@ -52,10 +51,9 @@ void AskForOptions(v8::Isolate* isolate, v8::HandleScope handle_scope(isolate); v8::Local context = isolate->GetCurrentContext(); v8::Context::Scope context_scope(context); - handler.Run( - *(request_details.get()), - mate::ConvertToV8(isolate, - base::Bind(&HandlerCallback, before_start, callback))); + handler.Run(*(request_details.get()), + mate::ConvertToV8(isolate, base::Bind(&HandlerCallback, + before_start, callback))); } bool IsErrorOptions(base::Value* value, int* error) { diff --git a/atom/browser/net/js_asker.h b/atom/browser/net/js_asker.h index 4753afb50b1..2117276d3bb 100644 --- a/atom/browser/net/js_asker.h +++ b/atom/browser/net/js_asker.h @@ -42,17 +42,16 @@ bool IsErrorOptions(base::Value* value, int* error); } // namespace internal -template +template class JsAsker : public RequestJob { public: JsAsker(net::URLRequest* request, net::NetworkDelegate* network_delegate) : RequestJob(request, network_delegate), weak_factory_(this) {} // Called by |CustomProtocolHandler| to store handler related information. - void SetHandlerInfo( - v8::Isolate* isolate, - net::URLRequestContextGetter* request_context_getter, - const JavaScriptHandler& handler) { + void SetHandlerInfo(v8::Isolate* isolate, + net::URLRequestContextGetter* request_context_getter, + const JavaScriptHandler& handler) { isolate_ = isolate; request_context_getter_ = request_context_getter; handler_ = handler; @@ -75,14 +74,11 @@ class JsAsker : public RequestJob { FillRequestDetails(request_details.get(), RequestJob::request()); content::BrowserThread::PostTask( content::BrowserThread::UI, FROM_HERE, - base::Bind(&internal::AskForOptions, - isolate_, - handler_, - base::Passed(&request_details), - base::Bind(&JsAsker::BeforeStartInUI, - weak_factory_.GetWeakPtr()), - base::Bind(&JsAsker::OnResponse, - weak_factory_.GetWeakPtr()))); + base::Bind( + &internal::AskForOptions, isolate_, handler_, + base::Passed(&request_details), + base::Bind(&JsAsker::BeforeStartInUI, weak_factory_.GetWeakPtr()), + base::Bind(&JsAsker::OnResponse, weak_factory_.GetWeakPtr()))); } int GetResponseCode() const override { return net::HTTP_OK; } diff --git a/atom/browser/net/url_request_async_asar_job.cc b/atom/browser/net/url_request_async_asar_job.cc index f7ddcc6141b..a51e08e486b 100644 --- a/atom/browser/net/url_request_async_asar_job.cc +++ b/atom/browser/net/url_request_async_asar_job.cc @@ -14,21 +14,20 @@ namespace atom { URLRequestAsyncAsarJob::URLRequestAsyncAsarJob( net::URLRequest* request, net::NetworkDelegate* network_delegate) - : JsAsker(request, network_delegate) { -} + : JsAsker(request, network_delegate) {} void URLRequestAsyncAsarJob::StartAsync(std::unique_ptr options) { base::FilePath::StringType file_path; if (options->IsType(base::Value::Type::DICTIONARY)) { - static_cast(options.get())->GetString( - "path", &file_path); + static_cast(options.get()) + ->GetString("path", &file_path); } else if (options->IsType(base::Value::Type::STRING)) { options->GetAsString(&file_path); } if (file_path.empty()) { - NotifyStartError(net::URLRequestStatus( - net::URLRequestStatus::FAILED, net::ERR_NOT_IMPLEMENTED)); + NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED, + net::ERR_NOT_IMPLEMENTED)); } else { asar::URLRequestAsarJob::Initialize( base::CreateSequencedTaskRunnerWithTraits( diff --git a/atom/browser/net/url_request_buffer_job.cc b/atom/browser/net/url_request_buffer_job.cc index 0b577762608..c244ca464fd 100644 --- a/atom/browser/net/url_request_buffer_job.cc +++ b/atom/browser/net/url_request_buffer_job.cc @@ -26,11 +26,10 @@ std::string GetExtFromURL(const GURL& url) { } // namespace -URLRequestBufferJob::URLRequestBufferJob( - net::URLRequest* request, net::NetworkDelegate* network_delegate) +URLRequestBufferJob::URLRequestBufferJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate) : JsAsker(request, network_delegate), - status_code_(net::HTTP_NOT_IMPLEMENTED) { -} + status_code_(net::HTTP_NOT_IMPLEMENTED) {} void URLRequestBufferJob::StartAsync(std::unique_ptr options) { const base::Value* binary = nullptr; @@ -54,8 +53,8 @@ void URLRequestBufferJob::StartAsync(std::unique_ptr options) { } if (!binary) { - NotifyStartError(net::URLRequestStatus( - net::URLRequestStatus::FAILED, net::ERR_NOT_IMPLEMENTED)); + NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED, + net::ERR_NOT_IMPLEMENTED)); return; } diff --git a/atom/browser/net/url_request_fetch_job.cc b/atom/browser/net/url_request_fetch_job.cc index bc3016d1d4a..fd563dcdf50 100644 --- a/atom/browser/net/url_request_fetch_job.cc +++ b/atom/browser/net/url_request_fetch_job.cc @@ -77,15 +77,14 @@ class ResponsePiper : public net::URLFetcherResponseWriter { } // namespace -URLRequestFetchJob::URLRequestFetchJob( - net::URLRequest* request, net::NetworkDelegate* network_delegate) +URLRequestFetchJob::URLRequestFetchJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate) : JsAsker(request, network_delegate), pending_buffer_size_(0), - write_num_bytes_(0) { -} + write_num_bytes_(0) {} -void URLRequestFetchJob::BeforeStartInUI( - v8::Isolate* isolate, v8::Local value) { +void URLRequestFetchJob::BeforeStartInUI(v8::Isolate* isolate, + v8::Local value) { mate::Dictionary options; if (!mate::ConvertFromV8(isolate, value, &options)) return; @@ -112,8 +111,8 @@ void URLRequestFetchJob::BeforeStartInUI( void URLRequestFetchJob::StartAsync(std::unique_ptr options) { if (!options->IsType(base::Value::Type::DICTIONARY)) { - NotifyStartError(net::URLRequestStatus( - net::URLRequestStatus::FAILED, net::ERR_NOT_IMPLEMENTED)); + NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED, + net::ERR_NOT_IMPLEMENTED)); return; } @@ -129,8 +128,8 @@ void URLRequestFetchJob::StartAsync(std::unique_ptr options) { // Check if URL is valid. GURL formated_url(url); if (!formated_url.is_valid()) { - NotifyStartError(net::URLRequestStatus( - net::URLRequestStatus::FAILED, net::ERR_INVALID_URL)); + NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED, + net::ERR_INVALID_URL)); return; } @@ -191,8 +190,8 @@ int URLRequestFetchJob::DataAvailable(net::IOBuffer* buffer, } // Write data to the pending buffer and clear them after the writing. - int bytes_read = BufferCopy(buffer, num_bytes, - pending_buffer_.get(), pending_buffer_size_); + int bytes_read = BufferCopy(buffer, num_bytes, pending_buffer_.get(), + pending_buffer_size_); ClearPendingBuffer(); ReadRawDataComplete(bytes_read); return bytes_read; @@ -218,8 +217,8 @@ int URLRequestFetchJob::ReadRawData(net::IOBuffer* dest, int dest_size) { } // Read from the write buffer and clear them after reading. - int bytes_read = BufferCopy(write_buffer_.get(), write_num_bytes_, - dest, dest_size); + int bytes_read = + BufferCopy(write_buffer_.get(), write_num_bytes_, dest, dest_size); net::CompletionCallback write_callback = write_callback_; ClearWriteBuffer(); write_callback.Run(bytes_read); @@ -265,8 +264,10 @@ void URLRequestFetchJob::OnURLFetchComplete(const net::URLFetcher* source) { } } -int URLRequestFetchJob::BufferCopy(net::IOBuffer* source, int num_bytes, - net::IOBuffer* target, int target_size) { +int URLRequestFetchJob::BufferCopy(net::IOBuffer* source, + int num_bytes, + net::IOBuffer* target, + int target_size) { int bytes_written = std::min(num_bytes, target_size); memcpy(target->data(), source->data(), bytes_written); return bytes_written; diff --git a/atom/browser/net/url_request_fetch_job.h b/atom/browser/net/url_request_fetch_job.h index 11ef11b7331..d073f896d1e 100644 --- a/atom/browser/net/url_request_fetch_job.h +++ b/atom/browser/net/url_request_fetch_job.h @@ -43,8 +43,10 @@ class URLRequestFetchJob : public JsAsker, void OnURLFetchComplete(const net::URLFetcher* source) override; private: - int BufferCopy(net::IOBuffer* source, int num_bytes, - net::IOBuffer* target, int target_size); + int BufferCopy(net::IOBuffer* source, + int num_bytes, + net::IOBuffer* target, + int target_size); void ClearPendingBuffer(); void ClearWriteBuffer(); diff --git a/atom/browser/net/url_request_string_job.cc b/atom/browser/net/url_request_string_job.cc index 60dc323d8ad..1a08752e335 100644 --- a/atom/browser/net/url_request_string_job.cc +++ b/atom/browser/net/url_request_string_job.cc @@ -11,10 +11,9 @@ namespace atom { -URLRequestStringJob::URLRequestStringJob( - net::URLRequest* request, net::NetworkDelegate* network_delegate) - : JsAsker(request, network_delegate) { -} +URLRequestStringJob::URLRequestStringJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate) + : JsAsker(request, network_delegate) {} void URLRequestStringJob::StartAsync(std::unique_ptr options) { if (options->IsType(base::Value::Type::DICTIONARY)) { diff --git a/atom/browser/node_debugger.cc b/atom/browser/node_debugger.cc index 191531d5bf3..8ad06a0a215 100644 --- a/atom/browser/node_debugger.cc +++ b/atom/browser/node_debugger.cc @@ -13,12 +13,9 @@ namespace atom { -NodeDebugger::NodeDebugger(node::Environment* env) - : env_(env) { -} +NodeDebugger::NodeDebugger(node::Environment* env) : env_(env) {} -NodeDebugger::~NodeDebugger() { -} +NodeDebugger::~NodeDebugger() {} void NodeDebugger::Start(node::MultiIsolatePlatform* platform) { auto inspector = env_->inspector_agent(); diff --git a/atom/browser/node_debugger.h b/atom/browser/node_debugger.h index f62eeadac55..06b64584e9a 100644 --- a/atom/browser/node_debugger.h +++ b/atom/browser/node_debugger.h @@ -10,7 +10,7 @@ namespace node { class Environment; class MultiIsolatePlatform; -} +} // namespace node namespace atom { diff --git a/atom/browser/osr/osr_output_device.cc b/atom/browser/osr/osr_output_device.cc index 1dec51c78d7..d169a567254 100644 --- a/atom/browser/osr/osr_output_device.cc +++ b/atom/browser/osr/osr_output_device.cc @@ -13,25 +13,22 @@ namespace atom { OffScreenOutputDevice::OffScreenOutputDevice(bool transparent, const OnPaintCallback& callback) - : transparent_(transparent), - callback_(callback), - active_(false) { + : transparent_(transparent), callback_(callback), active_(false) { DCHECK(!callback_.is_null()); } -OffScreenOutputDevice::~OffScreenOutputDevice() { -} +OffScreenOutputDevice::~OffScreenOutputDevice() {} -void OffScreenOutputDevice::Resize( - const gfx::Size& pixel_size, float scale_factor) { - if (viewport_pixel_size_ == pixel_size) return; +void OffScreenOutputDevice::Resize(const gfx::Size& pixel_size, + float scale_factor) { + if (viewport_pixel_size_ == pixel_size) + return; viewport_pixel_size_ = pixel_size; canvas_.reset(); bitmap_.reset(new SkBitmap); bitmap_->allocN32Pixels(viewport_pixel_size_.width(), - viewport_pixel_size_.height(), - !transparent_); + viewport_pixel_size_.height(), !transparent_); if (bitmap_->drawsNothing()) { NOTREACHED(); bitmap_.reset(); @@ -52,11 +49,9 @@ SkCanvas* OffScreenOutputDevice::BeginPaint(const gfx::Rect& damage_rect) { DCHECK(bitmap_.get()); damage_rect_ = damage_rect; - SkIRect damage = SkIRect::MakeXYWH( - damage_rect_.x(), - damage_rect_.y(), - damage_rect_.width(), - damage_rect_.height()); + SkIRect damage = + SkIRect::MakeXYWH(damage_rect_.x(), damage_rect_.y(), + damage_rect_.width(), damage_rect_.height()); if (transparent_) { bitmap_->erase(SK_ColorTRANSPARENT, damage); @@ -71,7 +66,8 @@ void OffScreenOutputDevice::EndPaint() { DCHECK(canvas_.get()); DCHECK(bitmap_.get()); - if (!bitmap_.get()) return; + if (!bitmap_.get()) + return; viz::SoftwareOutputDevice::EndPaint(); diff --git a/atom/browser/osr/osr_render_widget_host_view.cc b/atom/browser/osr/osr_render_widget_host_view.cc index 348551ea3e4..4f0643bff24 100644 --- a/atom/browser/osr/osr_render_widget_host_view.cc +++ b/atom/browser/osr/osr_render_widget_host_view.cc @@ -106,7 +106,8 @@ ui::MouseEvent UiMouseEventFromWebMouseEvent(blink::WebMouseEvent event) { ui::MouseWheelEvent UiMouseWheelEventFromWebMouseEvent( blink::WebMouseWheelEvent event) { return ui::MouseWheelEvent(UiMouseEventFromWebMouseEvent(event), - std::floor(event.delta_x), std::floor(event.delta_y)); + std::floor(event.delta_x), + std::floor(event.delta_y)); } } // namespace @@ -115,12 +116,12 @@ class AtomCopyFrameGenerator { public: AtomCopyFrameGenerator(OffScreenRenderWidgetHostView* view, int frame_rate_threshold_us) - : view_(view), - frame_retry_count_(0), - next_frame_time_(base::TimeTicks::Now()), - frame_duration_(base::TimeDelta::FromMicroseconds( - frame_rate_threshold_us)), - weak_ptr_factory_(this) { + : view_(view), + frame_retry_count_(0), + next_frame_time_(base::TimeTicks::Now()), + frame_duration_( + base::TimeDelta::FromMicroseconds(frame_rate_threshold_us)), + weak_ptr_factory_(this) { last_time_ = base::Time::Now(); } @@ -129,19 +130,18 @@ class AtomCopyFrameGenerator { return; auto request = std::make_unique( - viz::CopyOutputRequest::ResultFormat::RGBA_BITMAP, - base::BindOnce( - &AtomCopyFrameGenerator::CopyFromCompositingSurfaceHasResult, - weak_ptr_factory_.GetWeakPtr(), - damage_rect)); + viz::CopyOutputRequest::ResultFormat::RGBA_BITMAP, + base::BindOnce( + &AtomCopyFrameGenerator::CopyFromCompositingSurfaceHasResult, + weak_ptr_factory_.GetWeakPtr(), damage_rect)); request->set_area(gfx::Rect(view_->GetPhysicalBackingSize())); view_->GetRootLayer()->RequestCopyOfOutput(std::move(request)); } void set_frame_rate_threshold_us(int frame_rate_threshold_us) { - frame_duration_ = base::TimeDelta::FromMicroseconds( - frame_rate_threshold_us); + frame_duration_ = + base::TimeDelta::FromMicroseconds(frame_rate_threshold_us); } private: @@ -165,13 +165,11 @@ class AtomCopyFrameGenerator { base::TimeDelta next_frame_in = next_frame_time_ - now; if (next_frame_in > frame_duration_ / 4) { next_frame_time_ += frame_duration_; - content::BrowserThread::PostDelayedTask(content::BrowserThread::UI, - FROM_HERE, - base::Bind(&AtomCopyFrameGenerator::OnCopyFrameCaptureSuccess, - weak_ptr_factory_.GetWeakPtr(), - damage_rect, - bitmap), - next_frame_in); + content::BrowserThread::PostDelayedTask( + content::BrowserThread::UI, FROM_HERE, + base::Bind(&AtomCopyFrameGenerator::OnCopyFrameCaptureSuccess, + weak_ptr_factory_.GetWeakPtr(), damage_rect, bitmap), + next_frame_in); } else { next_frame_time_ = now + frame_duration_; OnCopyFrameCaptureSuccess(damage_rect, bitmap); @@ -187,16 +185,15 @@ class AtomCopyFrameGenerator { const bool force_frame = (++frame_retry_count_ <= kFrameRetryLimit); if (force_frame) { // Retry with the same |damage_rect|. - content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, - base::Bind(&AtomCopyFrameGenerator::GenerateCopyFrame, - weak_ptr_factory_.GetWeakPtr(), - damage_rect)); + content::BrowserThread::PostTask( + content::BrowserThread::UI, FROM_HERE, + base::Bind(&AtomCopyFrameGenerator::GenerateCopyFrame, + weak_ptr_factory_.GetWeakPtr(), damage_rect)); } } - void OnCopyFrameCaptureSuccess( - const gfx::Rect& damage_rect, - const std::shared_ptr& bitmap) { + void OnCopyFrameCaptureSuccess(const gfx::Rect& damage_rect, + const std::shared_ptr& bitmap) { base::AutoLock lock(onPaintLock_); view_->OnPaint(damage_rect, *bitmap); } @@ -223,20 +220,17 @@ class AtomBeginFrameTimer : public viz::DelayBasedTimeSourceClient { : callback_(callback) { time_source_.reset(new viz::DelayBasedTimeSource( content::BrowserThread::GetTaskRunnerForThread( - content::BrowserThread::UI).get())); + content::BrowserThread::UI) + .get())); time_source_->SetTimebaseAndInterval( - base::TimeTicks(), - base::TimeDelta::FromMicroseconds(frame_rate_threshold_us)); + base::TimeTicks(), + base::TimeDelta::FromMicroseconds(frame_rate_threshold_us)); time_source_->SetClient(this); } - void SetActive(bool active) { - time_source_->SetActive(active); - } + void SetActive(bool active) { time_source_->SetActive(active); } - bool IsActive() const { - return time_source_->Active(); - } + bool IsActive() const { return time_source_->Active(); } void SetFrameRateThresholdUs(int frame_rate_threshold_us) { time_source_->SetTimebaseAndInterval( @@ -245,9 +239,7 @@ class AtomBeginFrameTimer : public viz::DelayBasedTimeSourceClient { } private: - void OnTimerTick() override { - callback_.Run(); - } + void OnTimerTick() override { callback_.Run(); } const base::Closure callback_; std::unique_ptr time_source_; @@ -308,13 +300,11 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView( ui::ContextFactoryPrivate* context_factory_private = factory->GetContextFactoryPrivate(); compositor_.reset( - new ui::Compositor( - context_factory_private->AllocateFrameSinkId(), - content::GetContextFactory(), - context_factory_private, - base::ThreadTaskRunnerHandle::Get(), - false /* enable_surface_synchronization */, - false /* enable_pixel_canvas */)); + new ui::Compositor(context_factory_private->AllocateFrameSinkId(), + content::GetContextFactory(), context_factory_private, + base::ThreadTaskRunnerHandle::Get(), + false /* enable_surface_synchronization */, + false /* enable_pixel_canvas */)); compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget); compositor_->SetRootLayer(root_layer_.get()); #endif @@ -373,7 +363,8 @@ void OffScreenRenderWidgetHostView::OnBeginFrameTimerTick() { } void OffScreenRenderWidgetHostView::SendBeginFrame( - base::TimeTicks frame_time, base::TimeDelta vsync_period) { + base::TimeTicks frame_time, + base::TimeDelta vsync_period) { base::TimeTicks display_time = frame_time + vsync_period; base::TimeDelta estimated_browser_composite_time = @@ -382,11 +373,10 @@ void OffScreenRenderWidgetHostView::SendBeginFrame( base::TimeTicks deadline = display_time - estimated_browser_composite_time; - const viz::BeginFrameArgs& begin_frame_args = - viz::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, - begin_frame_source_.source_id(), - begin_frame_number_, frame_time, deadline, - vsync_period, viz::BeginFrameArgs::NORMAL); + const viz::BeginFrameArgs& begin_frame_args = viz::BeginFrameArgs::Create( + BEGINFRAME_FROM_HERE, begin_frame_source_.source_id(), + begin_frame_number_, frame_time, deadline, vsync_period, + viz::BeginFrameArgs::NORMAL); DCHECK(begin_frame_args.IsValid()); begin_frame_number_++; @@ -398,8 +388,7 @@ bool OffScreenRenderWidgetHostView::OnMessageReceived( const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(OffScreenRenderWidgetHostView, message) - IPC_MESSAGE_HANDLER(ViewHostMsg_SetNeedsBeginFrames, - SetNeedsBeginFrames) + IPC_MESSAGE_HANDLER(ViewHostMsg_SetNeedsBeginFrames, SetNeedsBeginFrames) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -453,8 +442,7 @@ ui::TextInputClient* OffScreenRenderWidgetHostView::GetTextInputClient() { return nullptr; } -void OffScreenRenderWidgetHostView::Focus() { -} +void OffScreenRenderWidgetHostView::Focus() {} bool OffScreenRenderWidgetHostView::HasFocus() const { return false; @@ -528,15 +516,13 @@ gfx::Size OffScreenRenderWidgetHostView::GetVisibleViewportSize() const { return size_; } -void OffScreenRenderWidgetHostView::SetInsets(const gfx::Insets& insets) { -} +void OffScreenRenderWidgetHostView::SetInsets(const gfx::Insets& insets) {} bool OffScreenRenderWidgetHostView::LockMouse() { return false; } -void OffScreenRenderWidgetHostView::UnlockMouse() { -} +void OffScreenRenderWidgetHostView::UnlockMouse() {} void OffScreenRenderWidgetHostView::DidCreateNewRendererCompositorFrameSink( viz::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink) { @@ -551,7 +537,7 @@ void OffScreenRenderWidgetHostView::SubmitCompositorFrame( const viz::LocalSurfaceId& local_surface_id, viz::CompositorFrame frame) { TRACE_EVENT0("electron", - "OffScreenRenderWidgetHostView::SubmitCompositorFrame"); + "OffScreenRenderWidgetHostView::SubmitCompositorFrame"); if (frame.metadata.root_scroll_offset != last_scroll_offset_) { last_scroll_offset_ = frame.metadata.root_scroll_offset; @@ -602,7 +588,8 @@ void OffScreenRenderWidgetHostView::ClearCompositorFrame() { } void OffScreenRenderWidgetHostView::InitAsPopup( - content::RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { + content::RenderWidgetHostView* parent_host_view, + const gfx::Rect& pos) { DCHECK_EQ(parent_host_view_, parent_host_view); if (parent_host_view_->popup_host_view_) { @@ -611,8 +598,9 @@ void OffScreenRenderWidgetHostView::InitAsPopup( parent_host_view_->set_popup_host_view(this); parent_host_view_->popup_bitmap_.reset(new SkBitmap); - parent_callback_ = base::Bind(&OffScreenRenderWidgetHostView::OnPopupPaint, - parent_host_view_->weak_ptr_factory_.GetWeakPtr()); + parent_callback_ = + base::Bind(&OffScreenRenderWidgetHostView::OnPopupPaint, + parent_host_view_->weak_ptr_factory_.GetWeakPtr()); popup_position_ = pos; @@ -621,24 +609,19 @@ void OffScreenRenderWidgetHostView::InitAsPopup( } void OffScreenRenderWidgetHostView::InitAsFullscreen( - content::RenderWidgetHostView *) { -} + content::RenderWidgetHostView*) {} -void OffScreenRenderWidgetHostView::UpdateCursor(const content::WebCursor &) { -} +void OffScreenRenderWidgetHostView::UpdateCursor(const content::WebCursor&) {} -void OffScreenRenderWidgetHostView::SetIsLoading(bool loading) { -} +void OffScreenRenderWidgetHostView::SetIsLoading(bool loading) {} void OffScreenRenderWidgetHostView::TextInputStateChanged( - const content::TextInputState& params) { -} + const content::TextInputState& params) {} -void OffScreenRenderWidgetHostView::ImeCancelComposition() { -} +void OffScreenRenderWidgetHostView::ImeCancelComposition() {} void OffScreenRenderWidgetHostView::RenderProcessGone(base::TerminationStatus, - int) { + int) { Destroy(); } @@ -671,12 +654,10 @@ void OffScreenRenderWidgetHostView::Destroy() { delete this; } -void OffScreenRenderWidgetHostView::SetTooltipText(const base::string16 &) { -} +void OffScreenRenderWidgetHostView::SetTooltipText(const base::string16&) {} void OffScreenRenderWidgetHostView::SelectionBoundsChanged( - const ViewHostMsg_SelectionBounds_Params &) { -} + const ViewHostMsg_SelectionBounds_Params&) {} void OffScreenRenderWidgetHostView::CopyFromSurface( const gfx::Rect& src_subrect, @@ -684,7 +665,7 @@ void OffScreenRenderWidgetHostView::CopyFromSurface( const content::ReadbackRequestCallback& callback, const SkColorType preferred_color_type) { GetDelegatedFrameHost()->CopyFromCompositingSurface( - src_subrect, dst_size, callback, preferred_color_type); + src_subrect, dst_size, callback, preferred_color_type); } void OffScreenRenderWidgetHostView::CopyFromSurfaceToVideoFrame( @@ -692,11 +673,11 @@ void OffScreenRenderWidgetHostView::CopyFromSurfaceToVideoFrame( scoped_refptr target, const base::Callback& callback) { GetDelegatedFrameHost()->CopyFromCompositingSurfaceToVideoFrame( - src_subrect, target, callback); + src_subrect, target, callback); } void OffScreenRenderWidgetHostView::BeginFrameSubscription( - std::unique_ptr subscriber) { + std::unique_ptr subscriber) { GetDelegatedFrameHost()->BeginFrameSubscription(std::move(subscriber)); } @@ -711,7 +692,7 @@ void OffScreenRenderWidgetHostView::InitAsGuest( parent_host_view_->RegisterGuestViewFrameSwappedCallback(guest_view); } -bool OffScreenRenderWidgetHostView::HasAcceleratedSurface(const gfx::Size &) { +bool OffScreenRenderWidgetHostView::HasAcceleratedSurface(const gfx::Size&) { return false; } @@ -720,8 +701,8 @@ gfx::Rect OffScreenRenderWidgetHostView::GetBoundsInRootWindow() { } void OffScreenRenderWidgetHostView::ImeCompositionRangeChanged( - const gfx::Range &, const std::vector&) { -} + const gfx::Range&, + const std::vector&) {} gfx::Size OffScreenRenderWidgetHostView::GetPhysicalBackingSize() const { return gfx::ScaleToCeiledSize(GetRequestedRendererSize(), scale_factor_); @@ -732,7 +713,7 @@ gfx::Size OffScreenRenderWidgetHostView::GetRequestedRendererSize() const { } content::RenderWidgetHostViewBase* - OffScreenRenderWidgetHostView::CreateViewForWidget( +OffScreenRenderWidgetHostView::CreateViewForWidget( content::RenderWidgetHost* render_widget_host, content::RenderWidgetHost* embedder_render_widget_host, content::WebContentsView* web_contents_view) { @@ -748,13 +729,8 @@ content::RenderWidgetHostViewBase* } return new OffScreenRenderWidgetHostView( - transparent_, - true, - embedder_host_view->GetFrameRate(), - callback_, - render_widget_host, - embedder_host_view, - native_window_); + transparent_, true, embedder_host_view->GetFrameRate(), callback_, + render_widget_host, embedder_host_view, native_window_); } #if !defined(OS_MACOSX) @@ -776,7 +752,7 @@ SkColor OffScreenRenderWidgetHostView::DelegatedFrameHostGetGutterColor( } gfx::Size OffScreenRenderWidgetHostView::DelegatedFrameHostDesiredSizeInDIP() - const { + const { return GetRootLayer()->bounds().size(); } @@ -795,8 +771,7 @@ viz::LocalSurfaceId OffScreenRenderWidgetHostView::GetLocalSurfaceId() const { return local_surface_id_; } -void OffScreenRenderWidgetHostView::OnBeginFrame() { -} +void OffScreenRenderWidgetHostView::OnBeginFrame() {} std::unique_ptr OffScreenRenderWidgetHostView::GetCompositorLock( @@ -816,8 +791,7 @@ bool OffScreenRenderWidgetHostView::TransformPointToLocalCoordSpace( gfx::Point* transformed_point) { // Transformations use physical pixels rather than DIP, so conversion // is necessary. - gfx::Point point_in_pixels = - gfx::ConvertPointToPixel(scale_factor_, point); + gfx::Point point_in_pixels = gfx::ConvertPointToPixel(scale_factor_, point); if (!GetDelegatedFrameHost()->TransformPointToLocalCoordSpace( point_in_pixels, original_surface, transformed_point)) { return false; @@ -897,22 +871,22 @@ void OffScreenRenderWidgetHostView::ProxyViewDestroyed( void OffScreenRenderWidgetHostView::RegisterGuestViewFrameSwappedCallback( content::RenderWidgetHostViewGuest* guest_host_view) { - guest_host_view->RegisterFrameSwappedCallback(std::make_unique( - base::Bind(&OffScreenRenderWidgetHostView::OnGuestViewFrameSwapped, - weak_ptr_factory_.GetWeakPtr(), - base::Unretained(guest_host_view)))); + guest_host_view->RegisterFrameSwappedCallback( + std::make_unique(base::Bind( + &OffScreenRenderWidgetHostView::OnGuestViewFrameSwapped, + weak_ptr_factory_.GetWeakPtr(), base::Unretained(guest_host_view)))); } void OffScreenRenderWidgetHostView::OnGuestViewFrameSwapped( content::RenderWidgetHostViewGuest* guest_host_view) { InvalidateBounds( - gfx::ConvertRectToPixel(scale_factor_, guest_host_view->GetViewBounds())); + gfx::ConvertRectToPixel(scale_factor_, guest_host_view->GetViewBounds())); RegisterGuestViewFrameSwappedCallback(guest_host_view); } std::unique_ptr - OffScreenRenderWidgetHostView::CreateSoftwareOutputDevice( +OffScreenRenderWidgetHostView::CreateSoftwareOutputDevice( ui::Compositor* compositor) { DCHECK_EQ(GetCompositor(), compositor); DCHECK(!copy_frame_generator_); @@ -921,9 +895,8 @@ std::unique_ptr ResizeRootLayer(); software_output_device_ = new OffScreenOutputDevice( - transparent_, - base::Bind(&OffScreenRenderWidgetHostView::OnPaint, - weak_ptr_factory_.GetWeakPtr())); + transparent_, base::Bind(&OffScreenRenderWidgetHostView::OnPaint, + weak_ptr_factory_.GetWeakPtr())); return base::WrapUnique(software_output_device_); } @@ -955,32 +928,34 @@ void OffScreenRenderWidgetHostView::SetNeedsBeginFrames( } } -void CopyBitmapTo( - const SkBitmap& destination, - const SkBitmap& source, - const gfx::Rect& pos) { +void CopyBitmapTo(const SkBitmap& destination, + const SkBitmap& source, + const gfx::Rect& pos) { char* src = static_cast(source.getPixels()); char* dest = static_cast(destination.getPixels()); int pixelsize = source.bytesPerPixel(); - int width = pos.x() + pos.width() <= destination.width() ? pos.width() - : pos.width() - ((pos.x() + pos.width()) - destination.width()); - int height = pos.y() + pos.height() <= destination.height() ? pos.height() - : pos.height() - ((pos.y() + pos.height()) - destination.height()); + int width = + pos.x() + pos.width() <= destination.width() + ? pos.width() + : pos.width() - ((pos.x() + pos.width()) - destination.width()); + int height = + pos.y() + pos.height() <= destination.height() + ? pos.height() + : pos.height() - ((pos.y() + pos.height()) - destination.height()); if (width > 0 && height > 0) { for (int i = 0; i < height; i++) { memcpy(dest + ((pos.y() + i) * destination.width() + pos.x()) * pixelsize, - src + (i * source.width()) * pixelsize, - width * pixelsize); + src + (i * source.width()) * pixelsize, width * pixelsize); } } destination.notifyPixelsChanged(); } -void OffScreenRenderWidgetHostView::OnPaint( - const gfx::Rect& damage_rect, const SkBitmap& bitmap) { +void OffScreenRenderWidgetHostView::OnPaint(const gfx::Rect& damage_rect, + const SkBitmap& bitmap) { TRACE_EVENT0("electron", "OffScreenRenderWidgetHostView::OnPaint"); HoldResize(); @@ -999,8 +974,8 @@ void OffScreenRenderWidgetHostView::OnPaint( damage.Union(pos); damages.push_back(pos); bitmaps.push_back(popup_bitmap_.get()); - originals.push_back(SkBitmapOperations::CreateTiledBitmap(bitmap, - pos.x(), pos.y(), pos.width(), pos.height())); + originals.push_back(SkBitmapOperations::CreateTiledBitmap( + bitmap, pos.x(), pos.y(), pos.width(), pos.height())); } for (auto proxy_view : proxy_views_) { @@ -1008,8 +983,8 @@ void OffScreenRenderWidgetHostView::OnPaint( damage.Union(pos); damages.push_back(pos); bitmaps.push_back(proxy_view->GetBitmap()); - originals.push_back(SkBitmapOperations::CreateTiledBitmap(bitmap, - pos.x(), pos.y(), pos.width(), pos.height())); + originals.push_back(SkBitmapOperations::CreateTiledBitmap( + bitmap, pos.x(), pos.y(), pos.width(), pos.height())); } for (size_t i = 0; i < damages.size(); i++) { @@ -1029,8 +1004,8 @@ void OffScreenRenderWidgetHostView::OnPaint( ReleaseResize(); } -void OffScreenRenderWidgetHostView::OnPopupPaint( - const gfx::Rect& damage_rect, const SkBitmap& bitmap) { +void OffScreenRenderWidgetHostView::OnPopupPaint(const gfx::Rect& damage_rect, + const SkBitmap& bitmap) { if (popup_host_view_ && popup_bitmap_.get()) popup_bitmap_.reset(new SkBitmap(bitmap)); InvalidateBounds(popup_host_view_->popup_position_); @@ -1053,7 +1028,8 @@ void OffScreenRenderWidgetHostView::ReleaseResize() { hold_resize_ = false; if (pending_resize_) { pending_resize_ = false; - content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, + content::BrowserThread::PostTask( + content::BrowserThread::UI, FROM_HERE, base::Bind(&OffScreenRenderWidgetHostView::WasResized, weak_ptr_factory_.GetWeakPtr())); } @@ -1099,8 +1075,9 @@ void OffScreenRenderWidgetHostView::ProcessMouseEvent( } if (!IsPopupWidget()) { - if (popup_host_view_ && popup_host_view_->popup_position_.Contains( - event.PositionInWidget().x, event.PositionInWidget().y)) { + if (popup_host_view_ && + popup_host_view_->popup_position_.Contains( + event.PositionInWidget().x, event.PositionInWidget().y)) { blink::WebMouseEvent popup_event(event); popup_event.SetPositionInWidget( popup_event.PositionInWidget().x - @@ -1131,7 +1108,7 @@ void OffScreenRenderWidgetHostView::ProcessMouseWheelEvent( proxy_event.PositionInWidget().y - bounds.y()); ui::MouseWheelEvent ui_event = - UiMouseWheelEventFromWebMouseEvent(proxy_event); + UiMouseWheelEventFromWebMouseEvent(proxy_event); proxy_view->OnEvent(&ui_event); return; } @@ -1139,7 +1116,7 @@ void OffScreenRenderWidgetHostView::ProcessMouseWheelEvent( if (!IsPopupWidget()) { if (popup_host_view_) { if (popup_host_view_->popup_position_.Contains( - event.PositionInWidget().x, event.PositionInWidget().y)) { + event.PositionInWidget().x, event.PositionInWidget().y)) { blink::WebMouseWheelEvent popup_event(event); popup_event.SetPositionInWidget( popup_event.PositionInWidget().x - @@ -1152,7 +1129,8 @@ void OffScreenRenderWidgetHostView::ProcessMouseWheelEvent( // Scrolling outside of the popup widget so destroy it. // Execute asynchronously to avoid deleting the widget from inside some // other callback. - content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, + content::BrowserThread::PostTask( + content::BrowserThread::UI, FROM_HERE, base::Bind(&OffScreenRenderWidgetHostView::CancelWidget, popup_host_view_->weak_ptr_factory_.GetWeakPtr())); } @@ -1284,11 +1262,11 @@ viz::FrameSinkId OffScreenRenderWidgetHostView::AllocateFrameSinkId( content::ImageTransportFactory* factory = content::ImageTransportFactory::GetInstance(); return is_guest_view_hack - ? factory->GetContextFactoryPrivate()->AllocateFrameSinkId() - : viz::FrameSinkId(base::checked_cast( - render_widget_host_->GetProcess()->GetID()), - base::checked_cast( - render_widget_host_->GetRoutingID())); + ? factory->GetContextFactoryPrivate()->AllocateFrameSinkId() + : viz::FrameSinkId(base::checked_cast( + render_widget_host_->GetProcess()->GetID()), + base::checked_cast( + render_widget_host_->GetRoutingID())); } void OffScreenRenderWidgetHostView::UpdateBackgroundColorFromRenderer( diff --git a/atom/browser/osr/osr_render_widget_host_view.h b/atom/browser/osr/osr_render_widget_host_view.h index df768cb5654..7e237096d06 100644 --- a/atom/browser/osr/osr_render_widget_host_view.h +++ b/atom/browser/osr/osr_render_widget_host_view.h @@ -30,8 +30,8 @@ #include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/renderer_host/render_widget_host_view_base.h" #include "content/browser/web_contents/web_contents_view.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/WebKit/public/platform/WebVector.h" +#include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/ime/text_input_client.h" #include "ui/compositor/compositor.h" #include "ui/compositor/layer_delegate.h" @@ -88,8 +88,8 @@ class OffScreenRenderWidgetHostView bool OnMessageReceived(const IPC::Message&) override; void InitAsChild(gfx::NativeView) override; content::RenderWidgetHost* GetRenderWidgetHost(void) const override; - void SetSize(const gfx::Size &) override; - void SetBounds(const gfx::Rect &) override; + void SetSize(const gfx::Size&) override; + void SetBounds(const gfx::Rect&) override; gfx::Vector2dF GetLastScrollOffset(void) const override; gfx::NativeView GetNativeView(void) const override; gfx::NativeViewAccessible GetNativeViewAccessible(void) override; @@ -126,54 +126,52 @@ class OffScreenRenderWidgetHostView viz::CompositorFrame frame) override; void ClearCompositorFrame(void) override; - void InitAsPopup(content::RenderWidgetHostView *rwhv, const gfx::Rect& rect) - override; - void InitAsFullscreen(content::RenderWidgetHostView *) override; - void UpdateCursor(const content::WebCursor &) override; + void InitAsPopup(content::RenderWidgetHostView* rwhv, + const gfx::Rect& rect) override; + void InitAsFullscreen(content::RenderWidgetHostView*) override; + void UpdateCursor(const content::WebCursor&) override; void SetIsLoading(bool is_loading) override; void TextInputStateChanged(const content::TextInputState& params) override; void ImeCancelComposition(void) override; void RenderProcessGone(base::TerminationStatus, int) override; void Destroy(void) override; - void SetTooltipText(const base::string16 &) override; + void SetTooltipText(const base::string16&) override; #if defined(OS_MACOSX) void SelectionChanged(const base::string16& text, size_t offset, const gfx::Range& range) override; #endif - void SelectionBoundsChanged(const ViewHostMsg_SelectionBounds_Params &) - override; - void CopyFromSurface( - const gfx::Rect& src_subrect, - const gfx::Size& dst_size, - const content::ReadbackRequestCallback& callback, - const SkColorType color_type) override; + void SelectionBoundsChanged( + const ViewHostMsg_SelectionBounds_Params&) override; + void CopyFromSurface(const gfx::Rect& src_subrect, + const gfx::Size& dst_size, + const content::ReadbackRequestCallback& callback, + const SkColorType color_type) override; void CopyFromSurfaceToVideoFrame( const gfx::Rect& src_subrect, scoped_refptr target, const base::Callback& callback) override; void BeginFrameSubscription( - std::unique_ptr) override; + std::unique_ptr) override; void EndFrameSubscription() override; - void InitAsGuest( - content::RenderWidgetHostView*, - content::RenderWidgetHostViewGuest*) override; - bool HasAcceleratedSurface(const gfx::Size &) override; + void InitAsGuest(content::RenderWidgetHostView*, + content::RenderWidgetHostViewGuest*) override; + bool HasAcceleratedSurface(const gfx::Size&) override; gfx::Rect GetBoundsInRootWindow(void) override; - void ImeCompositionRangeChanged( - const gfx::Range &, const std::vector&) override; + void ImeCompositionRangeChanged(const gfx::Range&, + const std::vector&) override; gfx::Size GetPhysicalBackingSize() const override; gfx::Size GetRequestedRendererSize() const override; content::RenderWidgetHostViewBase* CreateViewForWidget( - content::RenderWidgetHost*, - content::RenderWidgetHost*, - content::WebContentsView*) override; + content::RenderWidgetHost*, + content::RenderWidgetHost*, + content::WebContentsView*) override; #if !defined(OS_MACOSX) // content::DelegatedFrameHostClient: int DelegatedFrameHostGetGpuMemoryBufferClientId(void) const; - ui::Layer *DelegatedFrameHostGetLayer(void) const override; + ui::Layer* DelegatedFrameHostGetLayer(void) const override; bool DelegatedFrameHostIsVisible(void) const override; SkColor DelegatedFrameHostGetGutterColor(SkColor) const override; gfx::Size DelegatedFrameHostDesiredSizeInDIP(void) const override; @@ -188,10 +186,9 @@ class OffScreenRenderWidgetHostView void CompositorResizeLockEnded() override; #endif // !defined(OS_MACOSX) - bool TransformPointToLocalCoordSpace( - const gfx::Point& point, - const viz::SurfaceId& original_surface, - gfx::Point* transformed_point) override; + bool TransformPointToLocalCoordSpace(const gfx::Point& point, + const viz::SurfaceId& original_surface, + gfx::Point* transformed_point) override; bool TransformPointToCoordSpaceForView( const gfx::Point& point, RenderWidgetHostViewBase* target_view, @@ -209,8 +206,7 @@ class OffScreenRenderWidgetHostView void OnWindowClosed() override; void OnBeginFrameTimerTick(); - void SendBeginFrame(base::TimeTicks frame_time, - base::TimeDelta vsync_period); + void SendBeginFrame(base::TimeTicks frame_time, base::TimeDelta vsync_period); #if defined(OS_MACOSX) void CreatePlatformWidget(bool is_guest_view_hack); @@ -233,21 +229,18 @@ class OffScreenRenderWidgetHostView void OnPopupPaint(const gfx::Rect& damage_rect, const SkBitmap& bitmap); void OnProxyViewPaint(const gfx::Rect& damage_rect); - bool IsPopupWidget() const { - return popup_type_ != blink::kWebPopupTypeNone; - } + bool IsPopupWidget() const { return popup_type_ != blink::kWebPopupTypeNone; } void HoldResize(); void ReleaseResize(); void WasResized(); - void ProcessKeyboardEvent( - const content::NativeWebKeyboardEvent& event, - const ui::LatencyInfo& latency) override; + void ProcessKeyboardEvent(const content::NativeWebKeyboardEvent& event, + const ui::LatencyInfo& latency) override; void ProcessMouseEvent(const blink::WebMouseEvent& event, - const ui::LatencyInfo& latency) override; + const ui::LatencyInfo& latency) override; void ProcessMouseWheelEvent(const blink::WebMouseWheelEvent& event, - const ui::LatencyInfo& latency) override; + const ui::LatencyInfo& latency) override; void SetPainting(bool painting); bool IsPainting() const; @@ -262,8 +255,9 @@ class OffScreenRenderWidgetHostView void Invalidate(); void InvalidateBounds(const gfx::Rect&); - content::RenderWidgetHostImpl* render_widget_host() const - { return render_widget_host_; } + content::RenderWidgetHostImpl* render_widget_host() const { + return render_widget_host_; + } NativeWindow* window() const { return native_window_; } gfx::Size size() const { return size_; } float scale_factor() const { return scale_factor_; } @@ -276,9 +270,7 @@ class OffScreenRenderWidgetHostView child_host_view_ = child_view; } - viz::LocalSurfaceId local_surface_id() const { - return local_surface_id_; - } + viz::LocalSurfaceId local_surface_id() const { return local_surface_id_; } private: void SetupFrameRate(bool force); diff --git a/atom/browser/osr/osr_view_proxy.cc b/atom/browser/osr/osr_view_proxy.cc index 91366b9229e..21f64e481b4 100644 --- a/atom/browser/osr/osr_view_proxy.cc +++ b/atom/browser/osr/osr_view_proxy.cc @@ -34,8 +34,7 @@ const SkBitmap* OffscreenViewProxy::GetBitmap() const { void OffscreenViewProxy::SetBitmap(const SkBitmap& bitmap) { if (view_bounds_.width() == bitmap.width() && - view_bounds_.height() == bitmap.height() && - observer_) { + view_bounds_.height() == bitmap.height() && observer_) { view_bitmap_.reset(new SkBitmap(bitmap)); observer_->OnProxyViewPaint(view_bounds_); } diff --git a/atom/browser/osr/osr_view_proxy.h b/atom/browser/osr/osr_view_proxy.h index f4d6946aba1..47f001ef5ce 100644 --- a/atom/browser/osr/osr_view_proxy.h +++ b/atom/browser/osr/osr_view_proxy.h @@ -39,6 +39,7 @@ class OffscreenViewProxy { void OnEvent(ui::Event* event); void ResetView() { view_ = nullptr; } + private: views::View* view_; diff --git a/atom/browser/osr/osr_web_contents_view.cc b/atom/browser/osr/osr_web_contents_view.cc index 4cbc6a5c42f..6042a9e499e 100644 --- a/atom/browser/osr/osr_web_contents_view.cc +++ b/atom/browser/osr/osr_web_contents_view.cc @@ -13,7 +13,8 @@ namespace atom { OffScreenWebContentsView::OffScreenWebContentsView( - bool transparent, const OnPaintCallback& callback) + bool transparent, + const OnPaintCallback& callback) : transparent_(transparent), painting_(true), frame_rate_(60), @@ -39,26 +40,32 @@ void OffScreenWebContentsView::SetWebContents( #if !defined(OS_MACOSX) gfx::NativeView OffScreenWebContentsView::GetNativeView() const { - if (!web_contents_) return gfx::NativeView(); + if (!web_contents_) + return gfx::NativeView(); auto relay = NativeWindowRelay::FromWebContents(web_contents_); - if (!relay) return gfx::NativeView(); + if (!relay) + return gfx::NativeView(); return relay->window->GetNativeView(); } gfx::NativeView OffScreenWebContentsView::GetContentNativeView() const { - if (!web_contents_) return gfx::NativeView(); + if (!web_contents_) + return gfx::NativeView(); auto relay = NativeWindowRelay::FromWebContents(web_contents_); - if (!relay) return gfx::NativeView(); + if (!relay) + return gfx::NativeView(); return relay->window->GetNativeView(); } gfx::NativeWindow OffScreenWebContentsView::GetTopLevelNativeWindow() const { - if (!web_contents_) return gfx::NativeWindow(); + if (!web_contents_) + return gfx::NativeWindow(); auto relay = NativeWindowRelay::FromWebContents(web_contents_); - if (!relay) return gfx::NativeWindow(); + if (!relay) + return gfx::NativeWindow(); return relay->window->GetNativeWindow(); } #endif @@ -67,20 +74,15 @@ void OffScreenWebContentsView::GetContainerBounds(gfx::Rect* out) const { *out = GetViewBounds(); } -void OffScreenWebContentsView::SizeContents(const gfx::Size& size) { -} +void OffScreenWebContentsView::SizeContents(const gfx::Size& size) {} -void OffScreenWebContentsView::Focus() { -} +void OffScreenWebContentsView::Focus() {} -void OffScreenWebContentsView::SetInitialFocus() { -} +void OffScreenWebContentsView::SetInitialFocus() {} -void OffScreenWebContentsView::StoreFocus() { -} +void OffScreenWebContentsView::StoreFocus() {} -void OffScreenWebContentsView::RestoreFocus() { -} +void OffScreenWebContentsView::RestoreFocus() {} content::DropData* OffScreenWebContentsView::GetDropData() const { return nullptr; @@ -91,12 +93,12 @@ gfx::Rect OffScreenWebContentsView::GetViewBounds() const { } void OffScreenWebContentsView::CreateView(const gfx::Size& initial_size, - gfx::NativeView context) { -} + gfx::NativeView context) {} content::RenderWidgetHostViewBase* - OffScreenWebContentsView::CreateViewForWidget( - content::RenderWidgetHost* render_widget_host, bool is_guest_view_hack) { +OffScreenWebContentsView::CreateViewForWidget( + content::RenderWidgetHost* render_widget_host, + bool is_guest_view_hack) { if (render_widget_host->GetView()) { return static_cast( render_widget_host->GetView()); @@ -104,41 +106,31 @@ content::RenderWidgetHostViewBase* auto relay = NativeWindowRelay::FromWebContents(web_contents_); return new OffScreenRenderWidgetHostView( - transparent_, - painting_, - GetFrameRate(), - callback_, - render_widget_host, - nullptr, - relay->window.get()); + transparent_, painting_, GetFrameRate(), callback_, render_widget_host, + nullptr, relay->window.get()); } content::RenderWidgetHostViewBase* - OffScreenWebContentsView::CreateViewForPopupWidget( +OffScreenWebContentsView::CreateViewForPopupWidget( content::RenderWidgetHost* render_widget_host) { auto relay = NativeWindowRelay::FromWebContents(web_contents_); - content::WebContentsImpl *web_contents_impl = - static_cast(web_contents_); + content::WebContentsImpl* web_contents_impl = + static_cast(web_contents_); - OffScreenRenderWidgetHostView *view = - static_cast( - web_contents_impl->GetOuterWebContents() - ? web_contents_impl->GetOuterWebContents()->GetRenderWidgetHostView() - : web_contents_impl->GetRenderWidgetHostView()); + OffScreenRenderWidgetHostView* view = + static_cast( + web_contents_impl->GetOuterWebContents() + ? web_contents_impl->GetOuterWebContents() + ->GetRenderWidgetHostView() + : web_contents_impl->GetRenderWidgetHostView()); return new OffScreenRenderWidgetHostView( - transparent_, - true, - view->GetFrameRate(), - callback_, - render_widget_host, - view, - relay->window.get()); + transparent_, true, view->GetFrameRate(), callback_, render_widget_host, + view, relay->window.get()); } -void OffScreenWebContentsView::SetPageTitle(const base::string16& title) { -} +void OffScreenWebContentsView::SetPageTitle(const base::string16& title) {} void OffScreenWebContentsView::RenderViewCreated( content::RenderViewHost* host) { @@ -151,11 +143,9 @@ void OffScreenWebContentsView::RenderViewCreated( } void OffScreenWebContentsView::RenderViewSwappedIn( - content::RenderViewHost* host) { -} + content::RenderViewHost* host) {} -void OffScreenWebContentsView::SetOverscrollControllerEnabled(bool enabled) { -} +void OffScreenWebContentsView::SetOverscrollControllerEnabled(bool enabled) {} void OffScreenWebContentsView::GetScreenInfo( content::ScreenInfo* screen_info) const { @@ -171,15 +161,14 @@ void OffScreenWebContentsView::GetScreenInfo( screen_info->available_rect = gfx::Rect(GetView()->size()); } else { const display::Display display = - display::Screen::GetScreen()->GetPrimaryDisplay(); + display::Screen::GetScreen()->GetPrimaryDisplay(); screen_info->rect = display.bounds(); screen_info->available_rect = display.work_area(); } } #if defined(OS_MACOSX) -void OffScreenWebContentsView::SetAllowOtherViews(bool allow) { -} +void OffScreenWebContentsView::SetAllowOtherViews(bool allow) {} bool OffScreenWebContentsView::GetAllowOtherViews() const { return false; @@ -189,8 +178,7 @@ bool OffScreenWebContentsView::IsEventTracking() const { return false; } -void OffScreenWebContentsView::CloseTabAfterEventTracking() { -} +void OffScreenWebContentsView::CloseTabAfterEventTracking() {} #endif // defined(OS_MACOSX) void OffScreenWebContentsView::StartDragging( @@ -205,8 +193,7 @@ void OffScreenWebContentsView::StartDragging( } void OffScreenWebContentsView::UpdateDragCursor( - blink::WebDragOperation operation) { -} + blink::WebDragOperation operation) {} void OffScreenWebContentsView::SetPainting(bool painting) { auto* view = GetView(); diff --git a/atom/browser/osr/osr_web_contents_view.h b/atom/browser/osr/osr_web_contents_view.h index 788e55bf316..048bb093dc9 100644 --- a/atom/browser/osr/osr_web_contents_view.h +++ b/atom/browser/osr/osr_web_contents_view.h @@ -40,8 +40,8 @@ class OffScreenWebContentsView : public content::WebContentsView, void RestoreFocus() override; content::DropData* GetDropData() const override; gfx::Rect GetViewBounds() const override; - void CreateView( - const gfx::Size& initial_size, gfx::NativeView context) override; + void CreateView(const gfx::Size& initial_size, + gfx::NativeView context) override; content::RenderWidgetHostViewBase* CreateViewForWidget( content::RenderWidgetHost* render_widget_host, bool is_guest_view_hack) override; diff --git a/atom/browser/relauncher.cc b/atom/browser/relauncher.cc index 0f3f254b65f..35c6785e3d8 100644 --- a/atom/browser/relauncher.cc +++ b/atom/browser/relauncher.cc @@ -57,8 +57,8 @@ bool RelaunchAppWithHelper(const base::FilePath& helper, relaunch_argv.push_back(helper.value()); relaunch_argv.push_back(internal::kRelauncherTypeArg); - relaunch_argv.insert(relaunch_argv.end(), - relauncher_args.begin(), relauncher_args.end()); + relaunch_argv.insert(relaunch_argv.end(), relauncher_args.begin(), + relauncher_args.end()); relaunch_argv.push_back(internal::kRelauncherArgSeparator); @@ -84,8 +84,8 @@ bool RelaunchAppWithHelper(const base::FilePath& helper, // preserve these three FDs in forked processes, so kRelauncherSyncFD should // not conflict with them. static_assert(internal::kRelauncherSyncFD != STDIN_FILENO && - internal::kRelauncherSyncFD != STDOUT_FILENO && - internal::kRelauncherSyncFD != STDERR_FILENO, + internal::kRelauncherSyncFD != STDOUT_FILENO && + internal::kRelauncherSyncFD != STDERR_FILENO, "kRelauncherSyncFD must not conflict with stdio fds"); #endif diff --git a/atom/browser/relauncher_mac.cc b/atom/browser/relauncher_mac.cc index 74c135874be..54b3b58a177 100644 --- a/atom/browser/relauncher_mac.cc +++ b/atom/browser/relauncher_mac.cc @@ -41,7 +41,7 @@ void RelauncherSynchronizeWithParent() { return; } - struct kevent change = { 0 }; + struct kevent change = {0}; EV_SET(&change, parent_pid, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, NULL); if (kevent(kq.get(), &change, 1, nullptr, 0, nullptr) == -1) { PLOG(ERROR) << "kevent (add)"; @@ -68,8 +68,7 @@ void RelauncherSynchronizeWithParent() { return; } - if (event.filter != EVFILT_PROC || - event.fflags != NOTE_EXIT || + if (event.filter != EVFILT_PROC || event.fflags != NOTE_EXIT || event.ident != static_cast(parent_pid)) { LOG(ERROR) << "kevent (monitor): unexpected event, filter " << event.filter << ", fflags " << event.fflags << ", ident " << event.ident; diff --git a/atom/browser/relauncher_win.cc b/atom/browser/relauncher_win.cc index 3198b7ad73e..3092edb7b59 100644 --- a/atom/browser/relauncher_win.cc +++ b/atom/browser/relauncher_win.cc @@ -30,9 +30,9 @@ HANDLE GetParentProcessHandle(base::ProcessHandle handle) { } PROCESS_BASIC_INFORMATION pbi; - LONG status = NtQueryInformationProcess( - handle, ProcessBasicInformation, - &pbi, sizeof(PROCESS_BASIC_INFORMATION), NULL); + LONG status = + NtQueryInformationProcess(handle, ProcessBasicInformation, &pbi, + sizeof(PROCESS_BASIC_INFORMATION), NULL); if (!NT_SUCCESS(status)) { LOG(ERROR) << "NtQueryInformationProcess failed"; return NULL; @@ -57,7 +57,8 @@ StringType AddQuoteForArg(const StringType& arg) { if (arg[i] == '\\') { // Find the extent of this run of backslashes. size_t start = i, end = start + 1; - for (; end < arg.size() && arg[end] == '\\'; ++end) {} + for (; end < arg.size() && arg[end] == '\\'; ++end) { + } size_t backslash_count = end - start; // Backslashes are escapes only if the run is followed by a double quote. diff --git a/atom/browser/render_process_preferences.cc b/atom/browser/render_process_preferences.cc index d109c8714f7..934417fe274 100644 --- a/atom/browser/render_process_preferences.cc +++ b/atom/browser/render_process_preferences.cc @@ -12,16 +12,12 @@ namespace atom { RenderProcessPreferences::RenderProcessPreferences(const Predicate& predicate) - : predicate_(predicate), - next_id_(0), - cache_needs_update_(true) { - registrar_.Add(this, - content::NOTIFICATION_RENDERER_PROCESS_CREATED, + : predicate_(predicate), next_id_(0), cache_needs_update_(true) { + registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, content::NotificationService::AllBrowserContextsAndSources()); } -RenderProcessPreferences::~RenderProcessPreferences() { -} +RenderProcessPreferences::~RenderProcessPreferences() {} int RenderProcessPreferences::AddEntry(const base::DictionaryValue& entry) { int id = ++next_id_; diff --git a/atom/browser/resources/win/resource.h b/atom/browser/resources/win/resource.h index d35e16d082e..275374d3619 100644 --- a/atom/browser/resources/win/resource.h +++ b/atom/browser/resources/win/resource.h @@ -7,9 +7,9 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/atom/browser/session_preferences.cc b/atom/browser/session_preferences.cc index 0731036d66f..e9b21154646 100644 --- a/atom/browser/session_preferences.cc +++ b/atom/browser/session_preferences.cc @@ -27,8 +27,7 @@ SessionPreferences::SessionPreferences(content::BrowserContext* context) { context->SetUserData(&kLocatorKey, base::WrapUnique(this)); } -SessionPreferences::~SessionPreferences() { -} +SessionPreferences::~SessionPreferences() {} // static SessionPreferences* SessionPreferences::FromBrowserContext( @@ -38,7 +37,8 @@ SessionPreferences* SessionPreferences::FromBrowserContext( // static void SessionPreferences::AppendExtraCommandLineSwitches( - content::BrowserContext* context, base::CommandLine* command_line) { + content::BrowserContext* context, + base::CommandLine* command_line) { SessionPreferences* self = FromBrowserContext(context); if (!self) return; diff --git a/atom/browser/session_preferences.h b/atom/browser/session_preferences.h index ab0ba470bbf..545dbcaf6f5 100644 --- a/atom/browser/session_preferences.h +++ b/atom/browser/session_preferences.h @@ -21,8 +21,8 @@ class SessionPreferences : public base::SupportsUserData::Data { public: static SessionPreferences* FromBrowserContext( content::BrowserContext* context); - static void AppendExtraCommandLineSwitches( - content::BrowserContext* context, base::CommandLine* command_line); + static void AppendExtraCommandLineSwitches(content::BrowserContext* context, + base::CommandLine* command_line); explicit SessionPreferences(content::BrowserContext* context); ~SessionPreferences() override; diff --git a/atom/browser/ui/accelerator_util.cc b/atom/browser/ui/accelerator_util.cc index 9ebc4e10849..fd3072a463e 100644 --- a/atom/browser/ui/accelerator_util.cc +++ b/atom/browser/ui/accelerator_util.cc @@ -25,7 +25,7 @@ bool StringToAccelerator(const std::string& shortcut, } std::vector tokens = base::SplitString( - shortcut, "+", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); + shortcut, "+", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); // Now, parse it into an accelerator. int modifiers = ui::EF_NONE; @@ -79,7 +79,7 @@ void GenerateAcceleratorTable(AcceleratorTable* table, } else { ui::Accelerator accelerator; if (model->GetAcceleratorAtWithParams(i, true, &accelerator)) { - MenuItem item = { i, model }; + MenuItem item = {i, model}; (*table)[accelerator] = item; } } diff --git a/atom/browser/ui/accelerator_util.h b/atom/browser/ui/accelerator_util.h index 38f206f5376..c965e5da0b0 100644 --- a/atom/browser/ui/accelerator_util.h +++ b/atom/browser/ui/accelerator_util.h @@ -13,7 +13,10 @@ namespace accelerator_util { -typedef struct { int position; atom::AtomMenuModel* model; } MenuItem; +typedef struct { + int position; + atom::AtomMenuModel* model; +} MenuItem; typedef std::map AcceleratorTable; // Parse a string as an accelerator. diff --git a/atom/browser/ui/accelerator_util_views.cc b/atom/browser/ui/accelerator_util_views.cc index f8d994f82ad..086e7084c48 100644 --- a/atom/browser/ui/accelerator_util_views.cc +++ b/atom/browser/ui/accelerator_util_views.cc @@ -8,7 +8,6 @@ namespace accelerator_util { -void SetPlatformAccelerator(ui::Accelerator* accelerator) { -} +void SetPlatformAccelerator(ui::Accelerator* accelerator) {} } // namespace accelerator_util diff --git a/atom/browser/ui/atom_menu_model.cc b/atom/browser/ui/atom_menu_model.cc index 835e8d3dc45..e2453133adb 100644 --- a/atom/browser/ui/atom_menu_model.cc +++ b/atom/browser/ui/atom_menu_model.cc @@ -9,12 +9,9 @@ namespace atom { AtomMenuModel::AtomMenuModel(Delegate* delegate) - : ui::SimpleMenuModel(delegate), - delegate_(delegate) { -} + : ui::SimpleMenuModel(delegate), delegate_(delegate) {} -AtomMenuModel::~AtomMenuModel() { -} +AtomMenuModel::~AtomMenuModel() {} void AtomMenuModel::SetRole(int index, const base::string16& role) { int command_id = GetCommandIdAt(index); diff --git a/atom/browser/ui/atom_menu_model.h b/atom/browser/ui/atom_menu_model.h index f20cf2586dd..90de0ef3be8 100644 --- a/atom/browser/ui/atom_menu_model.h +++ b/atom/browser/ui/atom_menu_model.h @@ -27,8 +27,8 @@ class AtomMenuModel : public ui::SimpleMenuModel { // ui::SimpleMenuModel::Delegate: bool GetAcceleratorForCommandId(int command_id, ui::Accelerator* accelerator) const { - return GetAcceleratorForCommandIdWithParams( - command_id, false, accelerator); + return GetAcceleratorForCommandIdWithParams(command_id, false, + accelerator); } }; diff --git a/atom/browser/ui/autofill_popup.cc b/atom/browser/ui/autofill_popup.cc index 729bd814512..89b6213a49e 100644 --- a/atom/browser/ui/autofill_popup.cc +++ b/atom/browser/ui/autofill_popup.cc @@ -105,8 +105,7 @@ display::Display GetDisplayNearestPoint(const gfx::Point& point) { } // namespace AutofillPopup::AutofillPopup() { - bold_font_list_ = - gfx::FontList().DeriveWithWeight(gfx::Font::Weight::BOLD); + bold_font_list_ = gfx::FontList().DeriveWithWeight(gfx::Font::Weight::BOLD); smaller_font_list_ = gfx::FontList().DeriveWithSizeDelta(kSmallerFontSizeDelta); } @@ -115,11 +114,10 @@ AutofillPopup::~AutofillPopup() { Hide(); } -void AutofillPopup::CreateView( - content::RenderFrameHost* frame_host, - bool offscreen, - views::View* parent, - const gfx::RectF& r) { +void AutofillPopup::CreateView(content::RenderFrameHost* frame_host, + bool offscreen, + views::View* parent, + const gfx::RectF& r) { Hide(); frame_host_ = frame_host; @@ -133,8 +131,8 @@ void AutofillPopup::CreateView( #if defined(ENABLE_OSR) if (offscreen) { - auto* osr_rwhv = static_cast( - frame_host_->GetView()); + auto* osr_rwhv = + static_cast(frame_host_->GetView()); view_->view_proxy_.reset(new OffscreenViewProxy(view_)); osr_rwhv->AddViewProxy(view_->view_proxy_.get()); } @@ -192,19 +190,17 @@ void AutofillPopup::UpdatePopupBounds() { display::Display bottom_right_display = GetDisplayNearestPoint(bottom_right_corner_of_popup); - std::pair popup_x_and_width = - CalculatePopupXAndWidth(top_left_display, bottom_right_display, - desired_width, bounds, is_rtl); - std::pair popup_y_and_height = - CalculatePopupYAndHeight(top_left_display, bottom_right_display, - desired_height, bounds); + std::pair popup_x_and_width = CalculatePopupXAndWidth( + top_left_display, bottom_right_display, desired_width, bounds, is_rtl); + std::pair popup_y_and_height = CalculatePopupYAndHeight( + top_left_display, bottom_right_display, desired_height, bounds); - popup_bounds_ = gfx::Rect( - popup_x_and_width.first, popup_y_and_height.first, - popup_x_and_width.second, popup_y_and_height.second); - popup_bounds_in_view_ = gfx::Rect( - popup_bounds_in_view_.origin(), - gfx::Size(popup_x_and_width.second, popup_y_and_height.second)); + popup_bounds_ = + gfx::Rect(popup_x_and_width.first, popup_y_and_height.first, + popup_x_and_width.second, popup_y_and_height.second); + popup_bounds_in_view_ = + gfx::Rect(popup_bounds_in_view_.origin(), + gfx::Size(popup_x_and_width.second, popup_y_and_height.second)); } void AutofillPopup::OnViewBoundsChanged(views::View* view) { @@ -224,9 +220,10 @@ int AutofillPopup::GetDesiredPopupWidth() { int popup_width = element_bounds_.width(); for (size_t i = 0; i < values_.size(); ++i) { - int row_size = kEndPadding + 2 * kPopupBorderThickness + - gfx::GetStringWidth(GetValueAt(i), GetValueFontListForRow(i)) + - gfx::GetStringWidth(GetLabelAt(i), GetLabelFontListForRow(i)); + int row_size = + kEndPadding + 2 * kPopupBorderThickness + + gfx::GetStringWidth(GetValueAt(i), GetValueFontListForRow(i)) + + gfx::GetStringWidth(GetLabelAt(i), GetLabelFontListForRow(i)); if (GetLabelAt(i).length() > 0) row_size += kNamePadding + kEndPadding; @@ -255,8 +252,8 @@ const gfx::FontList& AutofillPopup::GetLabelFontListForRow(int index) const { ui::NativeTheme::ColorId AutofillPopup::GetBackgroundColorIDForRow( int index) const { return (view_ && index == view_->GetSelectedLine()) - ? ui::NativeTheme::kColorId_ResultsTableHoveredBackground - : ui::NativeTheme::kColorId_ResultsTableNormalBackground; + ? ui::NativeTheme::kColorId_ResultsTableHoveredBackground + : ui::NativeTheme::kColorId_ResultsTableNormalBackground; } int AutofillPopup::GetLineCount() { diff --git a/atom/browser/ui/certificate_trust_win.cc b/atom/browser/ui/certificate_trust_win.cc index b2e77def083..ac68d831305 100644 --- a/atom/browser/ui/certificate_trust_win.cc +++ b/atom/browser/ui/certificate_trust_win.cc @@ -19,22 +19,15 @@ namespace certificate_trust { // This requires prompting the user to confirm they trust the certificate. BOOL AddToTrustedRootStore(const PCCERT_CONTEXT cert_context, const scoped_refptr& cert) { - auto root_cert_store = CertOpenStore( - CERT_STORE_PROV_SYSTEM, - 0, - NULL, - CERT_SYSTEM_STORE_CURRENT_USER, - L"Root"); + auto root_cert_store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, NULL, + CERT_SYSTEM_STORE_CURRENT_USER, L"Root"); if (root_cert_store == NULL) { return false; } auto result = CertAddCertificateContextToStore( - root_cert_store, - cert_context, - CERT_STORE_ADD_REPLACE_EXISTING, - NULL); + root_cert_store, cert_context, CERT_STORE_ADD_REPLACE_EXISTING, NULL); if (result) { // force Chromium to reload it's database for this certificate @@ -57,7 +50,7 @@ CERT_CHAIN_PARA GetCertificateChainParameters() { cert_usage.dwType = USAGE_MATCH_TYPE_AND; cert_usage.Usage = enhkey_usage; - CERT_CHAIN_PARA params = { sizeof(CERT_CHAIN_PARA) }; + CERT_CHAIN_PARA params = {sizeof(CERT_CHAIN_PARA)}; params.RequestedUsage = cert_usage; return params; @@ -73,14 +66,8 @@ void ShowCertificateTrust(atom::NativeWindow* parent_window, auto params = GetCertificateChainParameters(); - if (CertGetCertificateChain(NULL, - cert_context.get(), - NULL, - NULL, - ¶ms, - NULL, - NULL, - &chain_context)) { + if (CertGetCertificateChain(NULL, cert_context.get(), NULL, NULL, ¶ms, + NULL, NULL, &chain_context)) { auto error_status = chain_context->TrustStatus.dwErrorStatus; if (error_status == CERT_TRUST_IS_SELF_SIGNED || error_status == CERT_TRUST_IS_UNTRUSTED_ROOT) { diff --git a/atom/browser/ui/cocoa/NSColor+Hex.h b/atom/browser/ui/cocoa/NSColor+Hex.h index 70847b42173..3584f034e08 100644 --- a/atom/browser/ui/cocoa/NSColor+Hex.h +++ b/atom/browser/ui/cocoa/NSColor+Hex.h @@ -9,7 +9,7 @@ #import -@interface NSColor(Hex) +@interface NSColor (Hex) + (NSColor*)colorWithHexColorString:(NSString*)hex; @end diff --git a/atom/browser/ui/cocoa/NSString+ANSI.h b/atom/browser/ui/cocoa/NSString+ANSI.h index 93e76b59e9b..9b691f3b07a 100644 --- a/atom/browser/ui/cocoa/NSString+ANSI.h +++ b/atom/browser/ui/cocoa/NSString+ANSI.h @@ -9,7 +9,7 @@ #import -@interface NSString(ANSI) +@interface NSString (ANSI) - (BOOL)containsANSICodes; - (NSMutableAttributedString*)attributedStringParsingANSICodes; @end diff --git a/atom/browser/ui/cocoa/atom_bundle_mover.h b/atom/browser/ui/cocoa/atom_bundle_mover.h index 36613454588..155c6b36570 100644 --- a/atom/browser/ui/cocoa/atom_bundle_mover.h +++ b/atom/browser/ui/cocoa/atom_bundle_mover.h @@ -26,7 +26,8 @@ class AtomBundleMover { static void Relaunch(NSString* destinationPath); static NSString* ShellQuotedString(NSString* string); static bool CopyBundle(NSString* srcPath, NSString* dstPath); - static bool AuthorizedInstall(NSString* srcPath, NSString* dstPath, + static bool AuthorizedInstall(NSString* srcPath, + NSString* dstPath, bool* canceled); static bool IsApplicationAtPathRunning(NSString* bundlePath); static bool DeleteOrTrash(NSString* path); diff --git a/atom/browser/ui/cocoa/atom_menu_controller.h b/atom/browser/ui/cocoa/atom_menu_controller.h index a230437f536..83e9010f0da 100644 --- a/atom/browser/ui/cocoa/atom_menu_controller.h +++ b/atom/browser/ui/cocoa/atom_menu_controller.h @@ -22,7 +22,7 @@ class AtomMenuModel; // allow for hierarchical menus). The tag is the index into that model for // that particular item. It is important that the model outlives this object // as it only maintains weak references. -@interface AtomMenuController : NSObject { +@interface AtomMenuController : NSObject { @protected atom::AtomMenuModel* model_; // weak base::scoped_nsobject menu_; diff --git a/atom/browser/ui/cocoa/atom_touch_bar.h b/atom/browser/ui/cocoa/atom_touch_bar.h index d36e45898ea..75f894b7fb7 100644 --- a/atom/browser/ui/cocoa/atom_touch_bar.h +++ b/atom/browser/ui/cocoa/atom_touch_bar.h @@ -17,7 +17,9 @@ #include "native_mate/constructor.h" #include "native_mate/persistent_dictionary.h" -@interface AtomTouchBar : NSObject { +@interface AtomTouchBar : NSObject { @protected std::vector ordered_settings_; std::map settings_; @@ -25,18 +27,25 @@ atom::NativeWindow* window_; } -- (id)initWithDelegate:(id)delegate window:(atom::NativeWindow*)window settings:(const std::vector&)settings; +- (id)initWithDelegate:(id)delegate + window:(atom::NativeWindow*)window + settings:(const std::vector&)settings; - (NSTouchBar*)makeTouchBar; - (NSTouchBar*)touchBarFromItemIdentifiers:(NSMutableArray*)items; -- (NSMutableArray*)identifiersFromSettings:(const std::vector&)settings; -- (void)refreshTouchBarItem:(NSTouchBar*)touchBar id:(const std::string&)item_id; -- (void)addNonDefaultTouchBarItems:(const std::vector&)items; -- (void)setEscapeTouchBarItem:(const mate::PersistentDictionary&)item forTouchBar:(NSTouchBar*)touchBar; +- (NSMutableArray*)identifiersFromSettings: + (const std::vector&)settings; +- (void)refreshTouchBarItem:(NSTouchBar*)touchBar + id:(const std::string&)item_id; +- (void)addNonDefaultTouchBarItems: + (const std::vector&)items; +- (void)setEscapeTouchBarItem:(const mate::PersistentDictionary&)item + forTouchBar:(NSTouchBar*)touchBar; - -- (NSString*)idFromIdentifier:(NSString*)identifier withPrefix:(NSString*)prefix; -- (NSTouchBarItemIdentifier)identifierFromID:(const std::string&)item_id type:(const std::string&)typere; +- (NSString*)idFromIdentifier:(NSString*)identifier + withPrefix:(NSString*)prefix; +- (NSTouchBarItemIdentifier)identifierFromID:(const std::string&)item_id + type:(const std::string&)typere; - (bool)hasItemWithID:(const std::string&)item_id; - (NSColor*)colorFromHexColorString:(const std::string&)colorString; @@ -47,19 +56,30 @@ // Helpers to create touch bar items - (NSTouchBarItem*)makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier; -- (NSTouchBarItem*)makeButtonForID:(NSString*)id withIdentifier:(NSString*)identifier; -- (NSTouchBarItem*)makeLabelForID:(NSString*)id withIdentifier:(NSString*)identifier; -- (NSTouchBarItem*)makeColorPickerForID:(NSString*)id withIdentifier:(NSString*)identifier; -- (NSTouchBarItem*)makeSliderForID:(NSString*)id withIdentifier:(NSString*)identifier; -- (NSTouchBarItem*)makePopoverForID:(NSString*)id withIdentifier:(NSString*)identifier; -- (NSTouchBarItem*)makeGroupForID:(NSString*)id withIdentifier:(NSString*)identifier; +- (NSTouchBarItem*)makeButtonForID:(NSString*)id + withIdentifier:(NSString*)identifier; +- (NSTouchBarItem*)makeLabelForID:(NSString*)id + withIdentifier:(NSString*)identifier; +- (NSTouchBarItem*)makeColorPickerForID:(NSString*)id + withIdentifier:(NSString*)identifier; +- (NSTouchBarItem*)makeSliderForID:(NSString*)id + withIdentifier:(NSString*)identifier; +- (NSTouchBarItem*)makePopoverForID:(NSString*)id + withIdentifier:(NSString*)identifier; +- (NSTouchBarItem*)makeGroupForID:(NSString*)id + withIdentifier:(NSString*)identifier; // Helpers to update touch bar items -- (void)updateButton:(NSCustomTouchBarItem*)item withSettings:(const mate::PersistentDictionary&)settings; -- (void)updateLabel:(NSCustomTouchBarItem*)item withSettings:(const mate::PersistentDictionary&)settings; -- (void)updateColorPicker:(NSColorPickerTouchBarItem*)item withSettings:(const mate::PersistentDictionary&)settings; -- (void)updateSlider:(NSSliderTouchBarItem*)item withSettings:(const mate::PersistentDictionary&)settings; -- (void)updatePopover:(NSPopoverTouchBarItem*)item withSettings:(const mate::PersistentDictionary&)settings; +- (void)updateButton:(NSCustomTouchBarItem*)item + withSettings:(const mate::PersistentDictionary&)settings; +- (void)updateLabel:(NSCustomTouchBarItem*)item + withSettings:(const mate::PersistentDictionary&)settings; +- (void)updateColorPicker:(NSColorPickerTouchBarItem*)item + withSettings:(const mate::PersistentDictionary&)settings; +- (void)updateSlider:(NSSliderTouchBarItem*)item + withSettings:(const mate::PersistentDictionary&)settings; +- (void)updatePopover:(NSPopoverTouchBarItem*)item + withSettings:(const mate::PersistentDictionary&)settings; @end diff --git a/atom/browser/ui/cocoa/touch_bar_forward_declarations.h b/atom/browser/ui/cocoa/touch_bar_forward_declarations.h index 062723bca67..66dbed7afb1 100644 --- a/atom/browser/ui/cocoa/touch_bar_forward_declarations.h +++ b/atom/browser/ui/cocoa/touch_bar_forward_declarations.h @@ -14,18 +14,18 @@ #pragma clang assume_nonnull begin @class NSTouchBar, NSTouchBarItem; -@class NSScrubber, NSScrubberItemView, NSScrubberArrangedView, NSScrubberTextItemView, NSScrubberImageItemView, NSScrubberSelectionStyle; -@protocol NSTouchBarDelegate, NSScrubberDelegate, NSScrubberDataSource, NSScrubberFlowLayoutDelegate, NSScrubberFlowLayout; +@class NSScrubber, NSScrubberItemView, NSScrubberArrangedView, + NSScrubberTextItemView, NSScrubberImageItemView, NSScrubberSelectionStyle; +@protocol NSTouchBarDelegate +, NSScrubberDelegate, NSScrubberDataSource, NSScrubberFlowLayoutDelegate, + NSScrubberFlowLayout; typedef float NSTouchBarItemPriority; static const NSTouchBarItemPriority NSTouchBarItemPriorityHigh = 1000; static const NSTouchBarItemPriority NSTouchBarItemPriorityNormal = 0; static const NSTouchBarItemPriority NSTouchBarItemPriorityLow = -1000; -enum NSScrubberMode { - NSScrubberModeFixed = 0, - NSScrubberModeFree -}; +enum NSScrubberMode { NSScrubberModeFixed = 0, NSScrubberModeFree }; typedef NSString* NSTouchBarItemIdentifier; typedef NSString* NSTouchBarCustomizationIdentifier; @@ -42,7 +42,7 @@ static const NSTouchBarItemIdentifier NSTouchBarItemIdentifierFlexibleSpace = static const NSTouchBarItemIdentifier NSTouchBarItemIdentifierOtherItemsProxy = @"NSTouchBarItemIdentifierOtherItemsProxy"; -@interface NSTouchBar : NSObject +@interface NSTouchBar : NSObject - (instancetype)init NS_DESIGNATED_INITIALIZER; - (nullable instancetype)initWithCoder:(NSCoder*)aDecoder @@ -55,7 +55,8 @@ static const NSTouchBarItemIdentifier NSTouchBarItemIdentifierOtherItemsProxy = @property(copy) NSArray* defaultItemIdentifiers; @property(copy, readonly) NSArray* itemIdentifiers; @property(copy, nullable) NSTouchBarItemIdentifier principalItemIdentifier; -@property(copy, nullable) NSTouchBarItemIdentifier escapeKeyReplacementItemIdentifier; +@property(copy, nullable) + NSTouchBarItemIdentifier escapeKeyReplacementItemIdentifier; @property(copy) NSSet* templateItems; @property(nullable, weak) id delegate; @@ -66,7 +67,7 @@ static const NSTouchBarItemIdentifier NSTouchBarItemIdentifierOtherItemsProxy = @end -@interface NSTouchBarItem : NSObject +@interface NSTouchBarItem : NSObject - (instancetype)initWithIdentifier:(NSTouchBarItemIdentifier)identifier NS_DESIGNATED_INITIALIZER; @@ -149,13 +150,15 @@ static const NSTouchBarItemIdentifier NSTouchBarItemIdentifierOtherItemsProxy = @end -@interface NSScrubberFlowLayout: NSObject +@interface NSScrubberFlowLayout : NSObject @end -@interface NSScrubberSelectionStyle : NSObject +@interface NSScrubberSelectionStyle : NSObject -@property(class, strong, readonly) NSScrubberSelectionStyle* outlineOverlayStyle; -@property(class, strong, readonly) NSScrubberSelectionStyle* roundedBackgroundStyle; +@property(class, strong, readonly) + NSScrubberSelectionStyle* outlineOverlayStyle; +@property(class, strong, readonly) + NSScrubberSelectionStyle* roundedBackgroundStyle; @end @@ -209,7 +212,7 @@ static const NSTouchBarItemIdentifier NSTouchBarItemIdentifierOtherItemsProxy = @end -@protocol NSTouchBarDelegate +@protocol NSTouchBarDelegate @optional - (nullable NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar @@ -217,24 +220,28 @@ static const NSTouchBarItemIdentifier NSTouchBarItemIdentifierOtherItemsProxy = @end -@protocol NSScrubberDelegate +@protocol NSScrubberDelegate -- (void)scrubber:(NSScrubber*)scrubber didHighlightItemAtIndex:(NSInteger)highlightedIndex; -- (void)scrubber:(NSScrubber*)scrubber didSelectItemAtIndex:(NSInteger)selectedIndex; +- (void)scrubber:(NSScrubber*)scrubber + didHighlightItemAtIndex:(NSInteger)highlightedIndex; +- (void)scrubber:(NSScrubber*)scrubber + didSelectItemAtIndex:(NSInteger)selectedIndex; @end -@protocol NSScrubberDataSource +@protocol NSScrubberDataSource - (NSInteger)numberOfItemsForScrubber:(NSScrubber*)scrubber; - (__kindof NSScrubberItemView*)scrubber:(NSScrubber*)scrubber - viewForItemAtIndex:(NSInteger)index; + viewForItemAtIndex:(NSInteger)index; @end -@protocol NSScrubberFlowLayoutDelegate +@protocol NSScrubberFlowLayoutDelegate -- (NSSize)scrubber:(NSScrubber *)scrubber layout:(NSScrubberFlowLayout *)layout sizeForItemAtIndex:(NSInteger)itemIndex; +- (NSSize)scrubber:(NSScrubber*)scrubber + layout:(NSScrubberFlowLayout*)layout + sizeForItemAtIndex:(NSInteger)itemIndex; @end diff --git a/atom/browser/ui/drag_util_views.cc b/atom/browser/ui/drag_util_views.cc index aded2ae0c34..ab2028daef3 100644 --- a/atom/browser/ui/drag_util_views.cc +++ b/atom/browser/ui/drag_util_views.cc @@ -23,8 +23,8 @@ void DragFileItems(const std::vector& files, // Set up our OLE machinery ui::OSExchangeData data; - button_drag_utils::SetDragImage(GURL(), files[0].LossyDisplayName(), - icon.AsImageSkia(), nullptr, + button_drag_utils::SetDragImage( + GURL(), files[0].LossyDisplayName(), icon.AsImageSkia(), nullptr, *views::Widget::GetTopLevelWidgetForNativeView(view), &data); std::vector file_infos; @@ -39,13 +39,11 @@ void DragFileItems(const std::vector& files, gfx::Point location = display::Screen::GetScreen()->GetCursorScreenPoint(); // TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below. - aura::client::GetDragDropClient(root_window)->StartDragAndDrop( - data, - root_window, - view, - location, - ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK, - ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); + aura::client::GetDragDropClient(root_window) + ->StartDragAndDrop( + data, root_window, view, location, + ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK, + ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); } } // namespace atom diff --git a/atom/browser/ui/file_dialog.h b/atom/browser/ui/file_dialog.h index 7363c0afdea..f9d9b968498 100644 --- a/atom/browser/ui/file_dialog.h +++ b/atom/browser/ui/file_dialog.h @@ -19,38 +19,37 @@ class NativeWindow; namespace file_dialog { // -typedef std::pair > Filter; +typedef std::pair> Filter; typedef std::vector Filters; enum FileDialogProperty { - FILE_DIALOG_OPEN_FILE = 1 << 0, - FILE_DIALOG_OPEN_DIRECTORY = 1 << 1, - FILE_DIALOG_MULTI_SELECTIONS = 1 << 2, - FILE_DIALOG_CREATE_DIRECTORY = 1 << 3, - FILE_DIALOG_SHOW_HIDDEN_FILES = 1 << 4, - FILE_DIALOG_PROMPT_TO_CREATE = 1 << 5, + FILE_DIALOG_OPEN_FILE = 1 << 0, + FILE_DIALOG_OPEN_DIRECTORY = 1 << 1, + FILE_DIALOG_MULTI_SELECTIONS = 1 << 2, + FILE_DIALOG_CREATE_DIRECTORY = 1 << 3, + FILE_DIALOG_SHOW_HIDDEN_FILES = 1 << 4, + FILE_DIALOG_PROMPT_TO_CREATE = 1 << 5, FILE_DIALOG_NO_RESOLVE_ALIASES = 1 << 6, FILE_DIALOG_TREAT_PACKAGE_APP_AS_DIRECTORY = 1 << 7, }; #if defined(MAS_BUILD) - typedef base::Callback& paths, - const std::vector& bookmarkData)> OpenDialogCallback; +typedef base::Callback& paths, + const std::vector& bookmarkData)> + OpenDialogCallback; - typedef base::Callback SaveDialogCallback; +typedef base::Callback + SaveDialogCallback; #else - typedef base::Callback& paths)> OpenDialogCallback; +typedef base::Callback& paths)> + OpenDialogCallback; - typedef base::Callback SaveDialogCallback; +typedef base::Callback + SaveDialogCallback; #endif struct DialogSettings { @@ -73,8 +72,7 @@ bool ShowOpenDialog(const DialogSettings& settings, void ShowOpenDialog(const DialogSettings& settings, const OpenDialogCallback& callback); -bool ShowSaveDialog(const DialogSettings& settings, - base::FilePath* path); +bool ShowSaveDialog(const DialogSettings& settings, base::FilePath* path); void ShowSaveDialog(const DialogSettings& settings, const SaveDialogCallback& callback); diff --git a/atom/browser/ui/file_dialog_win.cc b/atom/browser/ui/file_dialog_win.cc index f4473792e31..973e22bdb4a 100644 --- a/atom/browser/ui/file_dialog_win.cc +++ b/atom/browser/ui/file_dialog_win.cc @@ -30,15 +30,15 @@ namespace { // Distinguish directories from regular files. bool IsDirectory(const base::FilePath& path) { base::File::Info file_info; - return base::GetFileInfo(path, &file_info) ? - file_info.is_directory : path.EndsWithSeparator(); + return base::GetFileInfo(path, &file_info) ? file_info.is_directory + : path.EndsWithSeparator(); } void ConvertFilters(const Filters& filters, std::vector* buffer, std::vector* filterspec) { if (filters.empty()) { - COMDLG_FILTERSPEC spec = { L"All Files (*.*)", L"*.*" }; + COMDLG_FILTERSPEC spec = {L"All Files (*.*)", L"*.*"}; filterspec->push_back(spec); return; } @@ -75,8 +75,8 @@ class FileDialog { std::vector filterspec; ConvertFilters(settings.filters, &buffer, &filterspec); - dialog_.reset(new T(file_part.c_str(), options, NULL, - filterspec.data(), filterspec.size())); + dialog_.reset(new T(file_part.c_str(), options, NULL, filterspec.data(), + filterspec.size())); if (!settings.title.empty()) GetPtr()->SetTitle(base::UTF8ToUTF16(settings.title).c_str()); @@ -99,7 +99,7 @@ class FileDialog { for (size_t i = 0; i < filterspec.size(); ++i) { if (std::wstring(filterspec[i].pszSpec) != L"*.*") { // SetFileTypeIndex is regarded as one-based index. - GetPtr()->SetFileTypeIndex(i+1); + GetPtr()->SetFileTypeIndex(i + 1); GetPtr()->SetDefaultExtension(filterspec[i].pszSpec); break; } @@ -112,9 +112,10 @@ class FileDialog { bool Show(atom::NativeWindow* parent_window) { atom::UnresponsiveSuppressor suppressor; - HWND window = parent_window ? static_cast( - parent_window)->GetAcceleratedWidget() : - NULL; + HWND window = parent_window + ? static_cast(parent_window) + ->GetAcceleratedWidget() + : NULL; return dialog_->DoModal(window) == IDOK; } @@ -125,13 +126,12 @@ class FileDialog { private: // Set up the initial directory for the dialog. void SetDefaultFolder(const base::FilePath file_path) { - std::wstring directory = IsDirectory(file_path) ? - file_path.value() : - file_path.DirName().value(); + std::wstring directory = IsDirectory(file_path) + ? file_path.value() + : file_path.DirName().value(); ATL::CComPtr folder_item; - HRESULT hr = SHCreateItemFromParsingName(directory.c_str(), - NULL, + HRESULT hr = SHCreateItemFromParsingName(directory.c_str(), NULL, IID_PPV_ARGS(&folder_item)); if (SUCCEEDED(hr)) GetPtr()->SetFolder(folder_item); @@ -165,7 +165,7 @@ void RunOpenDialogInNewThread(const RunState& run_state, std::vector paths; bool result = ShowOpenDialog(settings, &paths); run_state.ui_task_runner->PostTask(FROM_HERE, - base::Bind(callback, result, paths)); + base::Bind(callback, result, paths)); run_state.ui_task_runner->DeleteSoon(FROM_HERE, run_state.dialog_thread); } @@ -198,8 +198,8 @@ bool ShowOpenDialog(const DialogSettings& settings, return false; ATL::CComPtr items; - HRESULT hr = static_cast(open_dialog.GetPtr())->GetResults( - &items); + HRESULT hr = + static_cast(open_dialog.GetPtr())->GetResults(&items); if (FAILED(hr)) return false; @@ -216,8 +216,8 @@ bool ShowOpenDialog(const DialogSettings& settings, return false; wchar_t file_name[MAX_PATH]; - hr = CShellFileOpenDialog::GetFileNameFromShellItem( - item, SIGDN_FILESYSPATH, file_name, MAX_PATH); + hr = CShellFileOpenDialog::GetFileNameFromShellItem(item, SIGDN_FILESYSPATH, + file_name, MAX_PATH); if (FAILED(hr)) return false; @@ -240,8 +240,7 @@ void ShowOpenDialog(const DialogSettings& settings, base::Bind(&RunOpenDialogInNewThread, run_state, settings, callback)); } -bool ShowSaveDialog(const DialogSettings& settings, - base::FilePath* path) { +bool ShowSaveDialog(const DialogSettings& settings, base::FilePath* path) { FileDialog save_dialog( settings, FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST | FOS_OVERWRITEPROMPT); if (!save_dialog.Show(settings.parent_window)) diff --git a/atom/browser/ui/message_box.h b/atom/browser/ui/message_box.h index 6c826719ee1..a00f1e1978f 100644 --- a/atom/browser/ui/message_box.h +++ b/atom/browser/ui/message_box.h @@ -28,7 +28,7 @@ enum MessageBoxType { }; enum MessageBoxOptions { - MESSAGE_BOX_NONE = 0, + MESSAGE_BOX_NONE = 0, MESSAGE_BOX_NO_LINK = 1 << 0, }; diff --git a/atom/browser/ui/message_box_gtk.cc b/atom/browser/ui/message_box_gtk.cc index 5b94ee8ee65..9104d9f1d47 100644 --- a/atom/browser/ui/message_box_gtk.cc +++ b/atom/browser/ui/message_box_gtk.cc @@ -227,7 +227,8 @@ void ShowErrorBox(const base::string16& title, const base::string16& content) { base::UTF16ToUTF8(content).c_str(), "", false) .RunSynchronous(); } else { - fprintf(stderr, ANSI_TEXT_BOLD ANSI_BACKGROUND_GRAY ANSI_FOREGROUND_RED + fprintf(stderr, + ANSI_TEXT_BOLD ANSI_BACKGROUND_GRAY ANSI_FOREGROUND_RED "%s\n" ANSI_FOREGROUND_BLACK "%s" ANSI_RESET "\n", base::UTF16ToUTF8(title).c_str(), base::UTF16ToUTF8(content).c_str()); diff --git a/atom/browser/ui/message_box_win.cc b/atom/browser/ui/message_box_win.cc index 6983138a008..db8447e9794 100644 --- a/atom/browser/ui/message_box_win.cc +++ b/atom/browser/ui/message_box_win.cc @@ -39,18 +39,18 @@ struct CommonButtonID { CommonButtonID GetCommonID(const base::string16& button) { base::string16 lower = base::ToLowerASCII(button); if (lower == L"ok") - return { TDCBF_OK_BUTTON, IDOK }; + return {TDCBF_OK_BUTTON, IDOK}; else if (lower == L"yes") - return { TDCBF_YES_BUTTON, IDYES }; + return {TDCBF_YES_BUTTON, IDYES}; else if (lower == L"no") - return { TDCBF_NO_BUTTON, IDNO }; + return {TDCBF_NO_BUTTON, IDNO}; else if (lower == L"cancel") - return { TDCBF_CANCEL_BUTTON, IDCANCEL }; + return {TDCBF_CANCEL_BUTTON, IDCANCEL}; else if (lower == L"retry") - return { TDCBF_RETRY_BUTTON, IDRETRY }; + return {TDCBF_RETRY_BUTTON, IDRETRY}; else if (lower == L"close") - return { TDCBF_CLOSE_BUTTON, IDCLOSE }; - return { -1, -1 }; + return {TDCBF_CLOSE_BUTTON, IDCLOSE}; + return {-1, -1}; } // Determine whether the buttons are common buttons, if so map common ID @@ -86,13 +86,13 @@ int ShowTaskDialogUTF16(NativeWindow* parent, bool* checkbox_checked, const gfx::ImageSkia& icon) { TASKDIALOG_FLAGS flags = - TDF_SIZE_TO_CONTENT | // Show all content. + TDF_SIZE_TO_CONTENT | // Show all content. TDF_ALLOW_DIALOG_CANCELLATION; // Allow canceling the dialog. - TASKDIALOGCONFIG config = { 0 }; - config.cbSize = sizeof(config); - config.hInstance = GetModuleHandle(NULL); - config.dwFlags = flags; + TASKDIALOGCONFIG config = {0}; + config.cbSize = sizeof(config); + config.hInstance = GetModuleHandle(NULL); + config.dwFlags = flags; if (parent) { config.hwndParent = @@ -223,8 +223,8 @@ void RunMessageBoxInNewThread(base::Thread* thread, content::BrowserThread::PostTask( content::BrowserThread::UI, FROM_HERE, base::Bind(callback, result, checkbox_checked)); - content::BrowserThread::DeleteSoon( - content::BrowserThread::UI, FROM_HERE, thread); + content::BrowserThread::DeleteSoon(content::BrowserThread::UI, FROM_HERE, + thread); } } // namespace diff --git a/atom/browser/ui/tray_icon.cc b/atom/browser/ui/tray_icon.cc index 240c8f73f85..b5332ac97b2 100644 --- a/atom/browser/ui/tray_icon.cc +++ b/atom/browser/ui/tray_icon.cc @@ -6,29 +6,22 @@ namespace atom { -TrayIcon::TrayIcon() { -} +TrayIcon::TrayIcon() {} -TrayIcon::~TrayIcon() { -} +TrayIcon::~TrayIcon() {} -void TrayIcon::SetPressedImage(ImageType image) { -} +void TrayIcon::SetPressedImage(ImageType image) {} -void TrayIcon::SetTitle(const std::string& title) { -} +void TrayIcon::SetTitle(const std::string& title) {} -void TrayIcon::SetHighlightMode(TrayIcon::HighlightMode mode) { -} +void TrayIcon::SetHighlightMode(TrayIcon::HighlightMode mode) {} void TrayIcon::DisplayBalloon(ImageType icon, const base::string16& title, - const base::string16& contents) { -} + const base::string16& contents) {} void TrayIcon::PopUpContextMenu(const gfx::Point& pos, - AtomMenuModel* menu_model) { -} + AtomMenuModel* menu_model) {} gfx::Rect TrayIcon::GetBounds() { return gfx::Rect(); diff --git a/atom/browser/ui/tray_icon.h b/atom/browser/ui/tray_icon.h index b396a3a807d..b91e6ea8a5d 100644 --- a/atom/browser/ui/tray_icon.h +++ b/atom/browser/ui/tray_icon.h @@ -45,8 +45,8 @@ class TrayIcon { // Sets the status icon highlight mode. This only works on macOS. enum HighlightMode { - ALWAYS, // Always highlight the tray icon - NEVER, // Never highlight the tray icon + ALWAYS, // Always highlight the tray icon + NEVER, // Never highlight the tray icon SELECTION // Highlight the tray icon when clicked or the menu is opened }; virtual void SetHighlightMode(HighlightMode mode); @@ -90,7 +90,7 @@ class TrayIcon { void NotifyMouseExited(const gfx::Point& location = gfx::Point(), int modifiers = 0); void NotifyMouseMoved(const gfx::Point& location = gfx::Point(), - int modifiers = 0); + int modifiers = 0); protected: TrayIcon(); diff --git a/atom/browser/ui/tray_icon_cocoa.h b/atom/browser/ui/tray_icon_cocoa.h index d0b124acab2..077657304aa 100644 --- a/atom/browser/ui/tray_icon_cocoa.h +++ b/atom/browser/ui/tray_icon_cocoa.h @@ -17,8 +17,7 @@ namespace atom { -class TrayIconCocoa : public TrayIcon, - public AtomMenuModel::Observer { +class TrayIconCocoa : public TrayIcon, public AtomMenuModel::Observer { public: TrayIconCocoa(); virtual ~TrayIconCocoa(); diff --git a/atom/browser/ui/tray_icon_gtk.cc b/atom/browser/ui/tray_icon_gtk.cc index eb7be1ed3b4..4c780285c80 100644 --- a/atom/browser/ui/tray_icon_gtk.cc +++ b/atom/browser/ui/tray_icon_gtk.cc @@ -21,11 +21,9 @@ int indicators_count; } // namespace -TrayIconGtk::TrayIconGtk() { -} +TrayIconGtk::TrayIconGtk() {} -TrayIconGtk::~TrayIconGtk() { -} +TrayIconGtk::~TrayIconGtk() {} void TrayIconGtk::SetImage(const gfx::Image& image) { if (icon_) { @@ -38,10 +36,9 @@ void TrayIconGtk::SetImage(const gfx::Image& image) { if (libgtkui::AppIndicatorIcon::CouldOpen()) { ++indicators_count; icon_.reset(new libgtkui::AppIndicatorIcon( - base::StringPrintf( - "%s%d", Browser::Get()->GetName().c_str(), indicators_count), - image.AsImageSkia(), - toolTip)); + base::StringPrintf("%s%d", Browser::Get()->GetName().c_str(), + indicators_count), + image.AsImageSkia(), toolTip)); } else { icon_.reset(new libgtkui::Gtk2StatusIcon(image.AsImageSkia(), toolTip)); } diff --git a/atom/browser/ui/tray_icon_gtk.h b/atom/browser/ui/tray_icon_gtk.h index 8cb00363f08..1a11da99e98 100644 --- a/atom/browser/ui/tray_icon_gtk.h +++ b/atom/browser/ui/tray_icon_gtk.h @@ -16,8 +16,7 @@ class StatusIconLinux; namespace atom { -class TrayIconGtk : public TrayIcon, - public views::StatusIconLinux::Delegate { +class TrayIconGtk : public TrayIcon, public views::StatusIconLinux::Delegate { public: TrayIconGtk(); virtual ~TrayIconGtk(); diff --git a/atom/browser/ui/tray_icon_observer.h b/atom/browser/ui/tray_icon_observer.h index 8213e8799eb..feb5fb8cfc7 100644 --- a/atom/browser/ui/tray_icon_observer.h +++ b/atom/browser/ui/tray_icon_observer.h @@ -11,7 +11,7 @@ namespace gfx { class Rect; class Point; -} +} // namespace gfx namespace atom { diff --git a/atom/browser/ui/views/autofill_popup_view.cc b/atom/browser/ui/views/autofill_popup_view.cc index 12c441a39d8..fc8e31ee2e3 100644 --- a/atom/browser/ui/views/autofill_popup_view.cc +++ b/atom/browser/ui/views/autofill_popup_view.cc @@ -18,9 +18,8 @@ namespace atom { -AutofillPopupView::AutofillPopupView( - AutofillPopup* popup, - views::Widget* parent_widget) +AutofillPopupView::AutofillPopupView(AutofillPopup* popup, + views::Widget* parent_widget) : popup_(popup), parent_widget_(parent_widget), #if defined(ENABLE_OSR) @@ -63,12 +62,10 @@ void AutofillPopupView::Show() { views::FocusManager* focus_manager = parent_widget_->GetFocusManager(); focus_manager->RegisterAccelerator( ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE), - ui::AcceleratorManager::kNormalPriority, - this); + ui::AcceleratorManager::kNormalPriority, this); focus_manager->RegisterAccelerator( ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE), - ui::AcceleratorManager::kNormalPriority, - this); + ui::AcceleratorManager::kNormalPriority, this); // The widget is destroyed by the corresponding NativeWidget, so we use // a weak pointer to hold the reference and don't have to worry about @@ -97,7 +94,7 @@ void AutofillPopupView::Show() { views::WidgetFocusManager::GetInstance()->AddFocusChangeListener(this); keypress_callback_ = base::Bind(&AutofillPopupView::HandleKeyPressEvent, - base::Unretained(this)); + base::Unretained(this)); auto host = popup_->frame_host_->GetRenderViewHost()->GetWidget(); host->AddKeyPressEventCallback(keypress_callback_); @@ -150,30 +147,26 @@ void AutofillPopupView::DrawAutofillEntry(gfx::Canvas* canvas, if (!popup_) return; - canvas->FillRect( - entry_rect, - GetNativeTheme()->GetSystemColor( - popup_->GetBackgroundColorIDForRow(index))); + canvas->FillRect(entry_rect, GetNativeTheme()->GetSystemColor( + popup_->GetBackgroundColorIDForRow(index))); const bool is_rtl = base::i18n::IsRTL(); const int text_align = - is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT : gfx::Canvas::TEXT_ALIGN_LEFT; + is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT : gfx::Canvas::TEXT_ALIGN_LEFT; gfx::Rect value_rect = entry_rect; value_rect.Inset(kEndPadding, 0); int x_align_left = value_rect.x(); const int value_width = gfx::GetStringWidth( - popup_->GetValueAt(index), - popup_->GetValueFontListForRow(index)); + popup_->GetValueAt(index), popup_->GetValueFontListForRow(index)); int value_x_align_left = x_align_left; value_x_align_left = - is_rtl ? value_rect.right() - value_width : value_rect.x(); + is_rtl ? value_rect.right() - value_width : value_rect.x(); canvas->DrawStringRectWithFlags( - popup_->GetValueAt(index), - popup_->GetValueFontListForRow(index), + popup_->GetValueAt(index), popup_->GetValueFontListForRow(index), GetNativeTheme()->GetSystemColor( - ui::NativeTheme::kColorId_ResultsTableNormalText), + ui::NativeTheme::kColorId_ResultsTableNormalText), gfx::Rect(value_x_align_left, value_rect.y(), value_width, value_rect.height()), text_align); @@ -181,15 +174,13 @@ void AutofillPopupView::DrawAutofillEntry(gfx::Canvas* canvas, // Draw the label text, if one exists. if (!popup_->GetLabelAt(index).empty()) { const int label_width = gfx::GetStringWidth( - popup_->GetLabelAt(index), - popup_->GetLabelFontListForRow(index)); + popup_->GetLabelAt(index), popup_->GetLabelFontListForRow(index)); int label_x_align_left = x_align_left; label_x_align_left = - is_rtl ? value_rect.x() : value_rect.right() - label_width; + is_rtl ? value_rect.x() : value_rect.right() - label_width; canvas->DrawStringRectWithFlags( - popup_->GetLabelAt(index), - popup_->GetLabelFontListForRow(index), + popup_->GetLabelAt(index), popup_->GetLabelFontListForRow(index), GetNativeTheme()->GetSystemColor( ui::NativeTheme::kColorId_ResultsTableNormalDimmedText), gfx::Rect(label_x_align_left, entry_rect.y(), label_width, @@ -229,8 +220,7 @@ void AutofillPopupView::OnPaint(gfx::Canvas* canvas) { std::unique_ptr paint_canvas; if (view_proxy_.get()) { bitmap.allocN32Pixels(popup_->popup_bounds_in_view_.width(), - popup_->popup_bounds_in_view_.height(), - true); + popup_->popup_bounds_in_view_.height(), true); paint_canvas.reset(new cc::SkiaPaintCanvas(bitmap)); draw_canvas = new gfx::Canvas(paint_canvas.get(), 1.0); } @@ -340,8 +330,7 @@ void AutofillPopupView::OnGestureEvent(ui::GestureEvent* event) { event->SetHandled(); } -bool AutofillPopupView::AcceleratorPressed( - const ui::Accelerator& accelerator) { +bool AutofillPopupView::AcceleratorPressed(const ui::Accelerator& accelerator) { if (accelerator.modifiers() != ui::EF_NONE) return false; diff --git a/atom/browser/ui/views/autofill_popup_view.h b/atom/browser/ui/views/autofill_popup_view.h index 234b6e57d0e..1e66ba7bc9c 100644 --- a/atom/browser/ui/views/autofill_popup_view.h +++ b/atom/browser/ui/views/autofill_popup_view.h @@ -68,13 +68,15 @@ class AutofillPopupView : public views::WidgetDelegateView, int GetSelectedLine() { return selected_line_.value_or(-1); } - void WriteDragDataForView( - views::View*, const gfx::Point&, ui::OSExchangeData*) override {} + void WriteDragDataForView(views::View*, + const gfx::Point&, + ui::OSExchangeData*) override {} int GetDragOperationsForView(views::View*, const gfx::Point&) override { return ui::DragDropTypes::DRAG_NONE; } - bool CanStartDragForView( - views::View*, const gfx::Point&, const gfx::Point&) override { + bool CanStartDragForView(views::View*, + const gfx::Point&, + const gfx::Point&) override { return false; } diff --git a/atom/browser/ui/views/frameless_view.cc b/atom/browser/ui/views/frameless_view.cc index 5182e1a0f7f..60220e93c30 100644 --- a/atom/browser/ui/views/frameless_view.cc +++ b/atom/browser/ui/views/frameless_view.cc @@ -21,11 +21,9 @@ const char kViewClassName[] = "FramelessView"; } // namespace -FramelessView::FramelessView() : window_(NULL), frame_(NULL) { -} +FramelessView::FramelessView() : window_(NULL), frame_(NULL) {} -FramelessView::~FramelessView() { -} +FramelessView::~FramelessView() {} void FramelessView::Init(NativeWindowViews* window, views::Widget* frame) { window_ = window; @@ -35,16 +33,17 @@ void FramelessView::Init(NativeWindowViews* window, views::Widget* frame) { int FramelessView::ResizingBorderHitTest(const gfx::Point& point) { // Check the frame first, as we allow a small area overlapping the contents // to be used for resize handles. - bool can_ever_resize = frame_->widget_delegate() ? - frame_->widget_delegate()->CanResize() : - false; + bool can_ever_resize = frame_->widget_delegate() + ? frame_->widget_delegate()->CanResize() + : false; // Don't allow overlapping resize handles when the window is maximized or // fullscreen, as it can't be resized in those states. - int resize_border = - frame_->IsMaximized() || frame_->IsFullscreen() ? 0 : - kResizeInsideBoundsSize; + int resize_border = frame_->IsMaximized() || frame_->IsFullscreen() + ? 0 + : kResizeInsideBoundsSize; return GetHTComponentForFrame(point, resize_border, resize_border, - kResizeAreaCornerSize, kResizeAreaCornerSize, can_ever_resize); + kResizeAreaCornerSize, kResizeAreaCornerSize, + can_ever_resize); } gfx::Rect FramelessView::GetBoundsForClientView() const { @@ -83,24 +82,21 @@ int FramelessView::NonClientHitTest(const gfx::Point& cursor) { } void FramelessView::GetWindowMask(const gfx::Size& size, - gfx::Path* window_mask) { -} + gfx::Path* window_mask) {} -void FramelessView::ResetWindowControls() { -} +void FramelessView::ResetWindowControls() {} -void FramelessView::UpdateWindowIcon() { -} +void FramelessView::UpdateWindowIcon() {} -void FramelessView::UpdateWindowTitle() { -} +void FramelessView::UpdateWindowTitle() {} -void FramelessView::SizeConstraintsChanged() { -} +void FramelessView::SizeConstraintsChanged() {} gfx::Size FramelessView::CalculatePreferredSize() const { - return frame_->non_client_view()->GetWindowBoundsForClientBounds( - gfx::Rect(frame_->client_view()->GetPreferredSize())).size(); + return frame_->non_client_view() + ->GetWindowBoundsForClientBounds( + gfx::Rect(frame_->client_view()->GetPreferredSize())) + .size(); } gfx::Size FramelessView::GetMinimumSize() const { diff --git a/atom/browser/ui/views/frameless_view.h b/atom/browser/ui/views/frameless_view.h index 112972c318c..ff8b44d2c9d 100644 --- a/atom/browser/ui/views/frameless_view.h +++ b/atom/browser/ui/views/frameless_view.h @@ -31,8 +31,7 @@ class FramelessView : public views::NonClientFrameView { gfx::Rect GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const override; int NonClientHitTest(const gfx::Point& point) override; - void GetWindowMask(const gfx::Size& size, - gfx::Path* window_mask) override; + void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) override; void ResetWindowControls() override; void UpdateWindowIcon() override; void UpdateWindowTitle() override; diff --git a/atom/browser/ui/views/global_menu_bar_x11.cc b/atom/browser/ui/views/global_menu_bar_x11.cc index f2ab22f70a6..13cf167be38 100644 --- a/atom/browser/ui/views/global_menu_bar_x11.cc +++ b/atom/browser/ui/views/global_menu_bar_x11.cc @@ -55,7 +55,7 @@ typedef DbusmenuMenuitem* (*dbusmenu_menuitem_property_set_int_func)( const char* property, int value); -typedef struct _DbusmenuServer DbusmenuServer; +typedef struct _DbusmenuServer DbusmenuServer; typedef DbusmenuServer* (*dbusmenu_server_new_func)(const char* object); typedef void (*dbusmenu_server_set_root_func)(DbusmenuServer* self, DbusmenuMenuitem* root); @@ -148,7 +148,7 @@ AtomMenuModel* ModelForMenuItem(DbusmenuMenuitem* item) { g_object_get_data(G_OBJECT(item), "model")); } -bool GetMenuItemID(DbusmenuMenuitem* item, int *id) { +bool GetMenuItemID(DbusmenuMenuitem* item, int* id) { gpointer id_ptr = g_object_get_data(G_OBJECT(item), "menu-id"); if (id_ptr != NULL) { *id = GPOINTER_TO_INT(id_ptr) - 1; @@ -168,9 +168,9 @@ void SetMenuItemID(DbusmenuMenuitem* item, int id) { std::string GetMenuModelStatus(AtomMenuModel* model) { std::string ret; for (int i = 0; i < model->GetItemCount(); ++i) { - int status = model->GetTypeAt(i) | (model->IsVisibleAt(i) << 3) - | (model->IsEnabledAt(i) << 4) - | (model->IsItemCheckedAt(i) << 5); + int status = model->GetTypeAt(i) | (model->IsVisibleAt(i) << 3) | + (model->IsEnabledAt(i) << 4) | + (model->IsItemCheckedAt(i) << 5); ret += base::StringPrintf( "%s-%X\n", base::UTF16ToUTF8(model->GetLabelAt(i)).c_str(), status); } @@ -252,8 +252,8 @@ void GlobalMenuBarX11::BuildMenuFromModel(AtomMenuModel* model, if (type == AtomMenuModel::TYPE_SUBMENU) { menuitem_property_set(item, kPropertyChildrenDisplay, kDisplaySubmenu); - g_signal_connect(item, "about-to-show", - G_CALLBACK(OnSubMenuShowThunk), this); + g_signal_connect(item, "about-to-show", G_CALLBACK(OnSubMenuShowThunk), + this); } else { ui::Accelerator accelerator; if (model->GetAcceleratorAtWithParams(i, true, &accelerator)) @@ -264,10 +264,11 @@ void GlobalMenuBarX11::BuildMenuFromModel(AtomMenuModel* model, if (type == AtomMenuModel::TYPE_CHECK || type == AtomMenuModel::TYPE_RADIO) { - menuitem_property_set(item, kPropertyToggleType, + menuitem_property_set( + item, kPropertyToggleType, type == AtomMenuModel::TYPE_CHECK ? kToggleCheck : kToggleRadio); menuitem_property_set_int(item, kPropertyToggleState, - model->IsItemCheckedAt(i)); + model->IsItemCheckedAt(i)); } } } @@ -291,8 +292,8 @@ void GlobalMenuBarX11::RegisterAccelerator(DbusmenuMenuitem* item, if (accelerator.IsShiftDown()) g_variant_builder_add(&builder, "s", "Shift"); - char* name = XKeysymToString(XKeysymForWindowsKeyCode( - accelerator.key_code(), false)); + char* name = + XKeysymToString(XKeysymForWindowsKeyCode(accelerator.key_code(), false)); if (!name) { NOTIMPLEMENTED(); return; @@ -332,7 +333,7 @@ void GlobalMenuBarX11::OnSubMenuShow(DbusmenuMenuitem* item) { g_free); // Clear children. - GList *children = menuitem_take_children(item); + GList* children = menuitem_take_children(item); g_list_foreach(children, reinterpret_cast(g_object_unref), NULL); g_list_free(children); diff --git a/atom/browser/ui/views/global_menu_bar_x11.h b/atom/browser/ui/views/global_menu_bar_x11.h index 8887ab57aa6..808be6e638d 100644 --- a/atom/browser/ui/views/global_menu_bar_x11.h +++ b/atom/browser/ui/views/global_menu_bar_x11.h @@ -14,7 +14,7 @@ #include "ui/gfx/native_widget_types.h" typedef struct _DbusmenuMenuitem DbusmenuMenuitem; -typedef struct _DbusmenuServer DbusmenuServer; +typedef struct _DbusmenuServer DbusmenuServer; namespace ui { class Accelerator; @@ -61,7 +61,10 @@ class GlobalMenuBarX11 { void RegisterAccelerator(DbusmenuMenuitem* item, const ui::Accelerator& accelerator); - CHROMEG_CALLBACK_1(GlobalMenuBarX11, void, OnItemActivated, DbusmenuMenuitem*, + CHROMEG_CALLBACK_1(GlobalMenuBarX11, + void, + OnItemActivated, + DbusmenuMenuitem*, unsigned int); CHROMEG_CALLBACK_0(GlobalMenuBarX11, void, OnSubMenuShow, DbusmenuMenuitem*); diff --git a/atom/browser/ui/views/menu_delegate.cc b/atom/browser/ui/views/menu_delegate.cc index 969ab3c3f4b..d8cb592293a 100644 --- a/atom/browser/ui/views/menu_delegate.cc +++ b/atom/browser/ui/views/menu_delegate.cc @@ -14,13 +14,9 @@ namespace atom { -MenuDelegate::MenuDelegate(MenuBar* menu_bar) - : menu_bar_(menu_bar), - id_(-1) { -} +MenuDelegate::MenuDelegate(MenuBar* menu_bar) : menu_bar_(menu_bar), id_(-1) {} -MenuDelegate::~MenuDelegate() { -} +MenuDelegate::~MenuDelegate() {} void MenuDelegate::RunMenu(AtomMenuModel* model, views::MenuButton* button) { gfx::Point screen_loc; @@ -38,12 +34,9 @@ void MenuDelegate::RunMenu(AtomMenuModel* model, views::MenuButton* button) { menu_runner_.reset(new views::MenuRunner( item, views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS)); - menu_runner_->RunMenuAt( - button->GetWidget()->GetTopLevelWidget(), - button, - bounds, - views::MENU_ANCHOR_TOPRIGHT, - ui::MENU_SOURCE_MOUSE); + menu_runner_->RunMenuAt(button->GetWidget()->GetTopLevelWidget(), button, + bounds, views::MENU_ANCHOR_TOPRIGHT, + ui::MENU_SOURCE_MOUSE); } void MenuDelegate::ExecuteCommand(int id) { diff --git a/atom/browser/ui/views/menu_delegate.h b/atom/browser/ui/views/menu_delegate.h index a55c52578eb..0ce46176c84 100644 --- a/atom/browser/ui/views/menu_delegate.h +++ b/atom/browser/ui/views/menu_delegate.h @@ -41,12 +41,11 @@ class MenuDelegate : public views::MenuDelegate { void WillShowMenu(views::MenuItemView* menu) override; void WillHideMenu(views::MenuItemView* menu) override; void OnMenuClosed(views::MenuItemView* menu) override; - views::MenuItemView* GetSiblingMenu( - views::MenuItemView* menu, - const gfx::Point& screen_point, - views::MenuAnchorPosition* anchor, - bool* has_mnemonics, - views::MenuButton** button) override; + views::MenuItemView* GetSiblingMenu(views::MenuItemView* menu, + const gfx::Point& screen_point, + views::MenuAnchorPosition* anchor, + bool* has_mnemonics, + views::MenuButton** button) override; private: MenuBar* menu_bar_; diff --git a/atom/browser/ui/views/menu_model_adapter.cc b/atom/browser/ui/views/menu_model_adapter.cc index 303cdb9babd..a3a581724fc 100644 --- a/atom/browser/ui/views/menu_model_adapter.cc +++ b/atom/browser/ui/views/menu_model_adapter.cc @@ -7,20 +7,17 @@ namespace atom { MenuModelAdapter::MenuModelAdapter(AtomMenuModel* menu_model) - : views::MenuModelAdapter(menu_model), - menu_model_(menu_model) { -} + : views::MenuModelAdapter(menu_model), menu_model_(menu_model) {} -MenuModelAdapter::~MenuModelAdapter() { -} +MenuModelAdapter::~MenuModelAdapter() {} bool MenuModelAdapter::GetAccelerator(int id, ui::Accelerator* accelerator) const { ui::MenuModel* model = menu_model_; int index = 0; if (ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index)) { - return static_cast(model)-> - GetAcceleratorAtWithParams(index, true, accelerator); + return static_cast(model)->GetAcceleratorAtWithParams( + index, true, accelerator); } return false; } diff --git a/atom/browser/ui/views/native_frame_view.cc b/atom/browser/ui/views/native_frame_view.cc index 134255f4845..aef66b949de 100644 --- a/atom/browser/ui/views/native_frame_view.cc +++ b/atom/browser/ui/views/native_frame_view.cc @@ -15,9 +15,7 @@ const char kViewClassName[] = "AtomNativeFrameView"; } // namespace NativeFrameView::NativeFrameView(NativeWindow* window, views::Widget* widget) - : views::NativeFrameView(widget), - window_(window) { -} + : views::NativeFrameView(widget), window_(window) {} gfx::Size NativeFrameView::GetMinimumSize() const { return window_->GetMinimumSize(); diff --git a/atom/browser/ui/views/submenu_button.cc b/atom/browser/ui/views/submenu_button.cc index b3116706bcc..07c4032a600 100644 --- a/atom/browser/ui/views/submenu_button.cc +++ b/atom/browser/ui/views/submenu_button.cc @@ -20,7 +20,8 @@ SubmenuButton::SubmenuButton(const base::string16& title, views::MenuButtonListener* menu_button_listener, const SkColor& background_color) : views::MenuButton(gfx::RemoveAcceleratorChar(title, '&', NULL, NULL), - menu_button_listener, false), + menu_button_listener, + false), accelerator_(0), show_underline_(false), underline_start_(0), @@ -44,16 +45,13 @@ SubmenuButton::SubmenuButton(const base::string16& title, color_utils::BlendTowardOppositeLuma(background_color_, 0x61)); } -SubmenuButton::~SubmenuButton() { -} +SubmenuButton::~SubmenuButton() {} std::unique_ptr SubmenuButton::CreateInkDropRipple() const { std::unique_ptr ripple( new views::FloodFillInkDropRipple( - size(), - GetInkDropCenterBasedOnLastEvent(), - GetInkDropBaseColor(), + size(), GetInkDropCenterBasedOnLastEvent(), GetInkDropBaseColor(), ink_drop_visible_opacity())); return ripple; } @@ -91,7 +89,8 @@ void SubmenuButton::PaintButtonContents(gfx::Canvas* canvas) { bool SubmenuButton::GetUnderlinePosition(const base::string16& text, base::char16* accelerator, - int* start, int* end) const { + int* start, + int* end) const { int pos, span; base::string16 trimmed = gfx::RemoveAcceleratorChar(text, '&', &pos, &span); if (pos > -1 && span != 0) { @@ -104,8 +103,9 @@ bool SubmenuButton::GetUnderlinePosition(const base::string16& text, return false; } -void SubmenuButton::GetCharacterPosition( - const base::string16& text, int index, int* pos) const { +void SubmenuButton::GetCharacterPosition(const base::string16& text, + int index, + int* pos) const { int height = 0; gfx::Canvas::SizeStringInt(text.substr(0, index), gfx::FontList(), pos, &height, 0, 0); diff --git a/atom/browser/ui/views/submenu_button.h b/atom/browser/ui/views/submenu_button.h index 0f7eddf4c91..f9d7516a5d0 100644 --- a/atom/browser/ui/views/submenu_button.h +++ b/atom/browser/ui/views/submenu_button.h @@ -33,9 +33,11 @@ class SubmenuButton : public views::MenuButton { private: bool GetUnderlinePosition(const base::string16& text, base::char16* accelerator, - int* start, int* end) const; - void GetCharacterPosition( - const base::string16& text, int index, int* pos) const; + int* start, + int* end) const; + void GetCharacterPosition(const base::string16& text, + int index, + int* pos) const; base::char16 accelerator_; diff --git a/atom/browser/ui/views/win_frame_view.cc b/atom/browser/ui/views/win_frame_view.cc index 3908a2774ef..91fdb8a9668 100644 --- a/atom/browser/ui/views/win_frame_view.cc +++ b/atom/browser/ui/views/win_frame_view.cc @@ -16,12 +16,9 @@ const char kViewClassName[] = "WinFrameView"; } // namespace +WinFrameView::WinFrameView() {} -WinFrameView::WinFrameView() { -} - -WinFrameView::~WinFrameView() { -} +WinFrameView::~WinFrameView() {} gfx::Rect WinFrameView::GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const { diff --git a/atom/browser/ui/webui/pdf_viewer_handler.cc b/atom/browser/ui/webui/pdf_viewer_handler.cc index ecbb09ea1d1..bc106a92c43 100644 --- a/atom/browser/ui/webui/pdf_viewer_handler.cc +++ b/atom/browser/ui/webui/pdf_viewer_handler.cc @@ -115,8 +115,8 @@ void PdfViewerHandler::Initialize(const base::ListValue* args) { initialize_callback_id_ = callback_id->CreateDeepCopy(); } - auto zoom_controller = WebContentsZoomController::FromWebContents( - web_ui()->GetWebContents()); + auto zoom_controller = + WebContentsZoomController::FromWebContents(web_ui()->GetWebContents()); zoom_controller->SetZoomMode(WebContentsZoomController::ZOOM_MODE_MANUAL); zoom_controller->SetZoomLevel(0); } @@ -128,12 +128,11 @@ void PdfViewerHandler::GetDefaultZoom(const base::ListValue* args) { const base::Value* callback_id; CHECK(args->Get(0, &callback_id)); - auto zoom_controller = WebContentsZoomController::FromWebContents( - web_ui()->GetWebContents()); + auto zoom_controller = + WebContentsZoomController::FromWebContents(web_ui()->GetWebContents()); double zoom_level = zoom_controller->GetDefaultZoomLevel(); ResolveJavascriptCallback( - *callback_id, - base::Value(content::ZoomLevelToZoomFactor(zoom_level))); + *callback_id, base::Value(content::ZoomLevelToZoomFactor(zoom_level))); } void PdfViewerHandler::GetInitialZoom(const base::ListValue* args) { @@ -143,12 +142,11 @@ void PdfViewerHandler::GetInitialZoom(const base::ListValue* args) { const base::Value* callback_id; CHECK(args->Get(0, &callback_id)); - auto zoom_controller = WebContentsZoomController::FromWebContents( - web_ui()->GetWebContents()); + auto zoom_controller = + WebContentsZoomController::FromWebContents(web_ui()->GetWebContents()); double zoom_level = zoom_controller->GetZoomLevel(); ResolveJavascriptCallback( - *callback_id, - base::Value(content::ZoomLevelToZoomFactor(zoom_level))); + *callback_id, base::Value(content::ZoomLevelToZoomFactor(zoom_level))); } void PdfViewerHandler::SetZoom(const base::ListValue* args) { @@ -160,8 +158,8 @@ void PdfViewerHandler::SetZoom(const base::ListValue* args) { double zoom_level = 0.0; CHECK(args->GetDouble(1, &zoom_level)); - auto zoom_controller = WebContentsZoomController::FromWebContents( - web_ui()->GetWebContents()); + auto zoom_controller = + WebContentsZoomController::FromWebContents(web_ui()->GetWebContents()); zoom_controller->SetZoomLevel(zoom_level); ResolveJavascriptCallback(*callback_id, base::Value(zoom_level)); } @@ -204,11 +202,12 @@ void PdfViewerHandler::Reload(const base::ListValue* args) { } void PdfViewerHandler::OnZoomLevelChanged(content::WebContents* web_contents, - double level, bool is_temporary) { + double level, + bool is_temporary) { if (web_ui()->GetWebContents() == web_contents) { CallJavascriptFunction("cr.webUIListenerCallback", - base::Value("onZoomLevelChanged"), - base::Value(content::ZoomLevelToZoomFactor(level))); + base::Value("onZoomLevelChanged"), + base::Value(content::ZoomLevelToZoomFactor(level))); } } diff --git a/atom/browser/ui/webui/pdf_viewer_handler.h b/atom/browser/ui/webui/pdf_viewer_handler.h index 73d2983a74b..81c7d98d780 100644 --- a/atom/browser/ui/webui/pdf_viewer_handler.h +++ b/atom/browser/ui/webui/pdf_viewer_handler.h @@ -47,8 +47,9 @@ class PdfViewerHandler : public content::WebUIMessageHandler, void SetZoom(const base::ListValue* args); void GetStrings(const base::ListValue* args); void Reload(const base::ListValue* args); - void OnZoomLevelChanged(content::WebContents* web_contents, double level, - bool is_temporary); + void OnZoomLevelChanged(content::WebContents* web_contents, + double level, + bool is_temporary); void AddObserver(); void RemoveObserver(); std::unique_ptr initialize_callback_id_; diff --git a/atom/browser/ui/webui/pdf_viewer_ui.h b/atom/browser/ui/webui/pdf_viewer_ui.h index c4d2b544610..75bf58d239d 100644 --- a/atom/browser/ui/webui/pdf_viewer_ui.h +++ b/atom/browser/ui/webui/pdf_viewer_ui.h @@ -19,7 +19,7 @@ namespace content { class BrowserContext; struct StreamInfo; -} +} // namespace content namespace atom { diff --git a/atom/browser/ui/win/atom_desktop_native_widget_aura.cc b/atom/browser/ui/win/atom_desktop_native_widget_aura.cc index f9f0d1e8610..21300409add 100644 --- a/atom/browser/ui/win/atom_desktop_native_widget_aura.cc +++ b/atom/browser/ui/win/atom_desktop_native_widget_aura.cc @@ -27,11 +27,11 @@ void AtomDesktopNativeWidgetAura::OnWindowActivated( wm::ActivationChangeObserver::ActivationReason reason, aura::Window* gained_active, aura::Window* lost_active) { - views::DesktopNativeWidgetAura::OnWindowActivated( - reason, gained_active, lost_active); + views::DesktopNativeWidgetAura::OnWindowActivated(reason, gained_active, + lost_active); if (lost_active != nullptr) { auto* tooltip_controller = static_cast( - wm::GetTooltipClient(lost_active->GetRootWindow())); + wm::GetTooltipClient(lost_active->GetRootWindow())); // This will cause the tooltip to be hidden when a window is deactivated, // as it should be. diff --git a/atom/browser/ui/win/atom_desktop_native_widget_aura.h b/atom/browser/ui/win/atom_desktop_native_widget_aura.h index 8aca097d9f7..81c6f2b394a 100644 --- a/atom/browser/ui/win/atom_desktop_native_widget_aura.h +++ b/atom/browser/ui/win/atom_desktop_native_widget_aura.h @@ -19,10 +19,9 @@ class AtomDesktopNativeWidgetAura : public views::DesktopNativeWidgetAura { void Activate() override; private: - void OnWindowActivated( - wm::ActivationChangeObserver::ActivationReason reason, - aura::Window* gained_active, - aura::Window* lost_active) override; + void OnWindowActivated(wm::ActivationChangeObserver::ActivationReason reason, + aura::Window* gained_active, + aura::Window* lost_active) override; DISALLOW_COPY_AND_ASSIGN(AtomDesktopNativeWidgetAura); }; diff --git a/atom/browser/ui/win/atom_desktop_window_tree_host_win.cc b/atom/browser/ui/win/atom_desktop_window_tree_host_win.cc index 3da0241a27a..97857d6515a 100644 --- a/atom/browser/ui/win/atom_desktop_window_tree_host_win.cc +++ b/atom/browser/ui/win/atom_desktop_window_tree_host_win.cc @@ -12,16 +12,16 @@ AtomDesktopWindowTreeHostWin::AtomDesktopWindowTreeHostWin( MessageHandlerDelegate* delegate, views::internal::NativeWidgetDelegate* native_widget_delegate, views::DesktopNativeWidgetAura* desktop_native_widget_aura) - : views::DesktopWindowTreeHostWin(native_widget_delegate, - desktop_native_widget_aura), - delegate_(delegate) { -} + : views::DesktopWindowTreeHostWin(native_widget_delegate, + desktop_native_widget_aura), + delegate_(delegate) {} -AtomDesktopWindowTreeHostWin::~AtomDesktopWindowTreeHostWin() { -} +AtomDesktopWindowTreeHostWin::~AtomDesktopWindowTreeHostWin() {} -bool AtomDesktopWindowTreeHostWin::PreHandleMSG( - UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) { +bool AtomDesktopWindowTreeHostWin::PreHandleMSG(UINT message, + WPARAM w_param, + LPARAM l_param, + LRESULT* result) { return delegate_->PreHandleMSG(message, w_param, l_param, result); } diff --git a/atom/browser/ui/win/atom_desktop_window_tree_host_win.h b/atom/browser/ui/win/atom_desktop_window_tree_host_win.h index b0164f2ab6c..30af3cc162b 100644 --- a/atom/browser/ui/win/atom_desktop_window_tree_host_win.h +++ b/atom/browser/ui/win/atom_desktop_window_tree_host_win.h @@ -25,8 +25,10 @@ class AtomDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin { ~AtomDesktopWindowTreeHostWin() override; protected: - bool PreHandleMSG( - UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) override; + bool PreHandleMSG(UINT message, + WPARAM w_param, + LPARAM l_param, + LRESULT* result) override; bool HasNativeFrame() const override; private: diff --git a/atom/browser/ui/win/jump_list.cc b/atom/browser/ui/win/jump_list.cc index de2ee931de7..6af235e756c 100644 --- a/atom/browser/ui/win/jump_list.cc +++ b/atom/browser/ui/win/jump_list.cc @@ -12,8 +12,8 @@ namespace { -using atom::JumpListItem; using atom::JumpListCategory; +using atom::JumpListItem; using atom::JumpListResult; bool AppendTask(const JumpListItem& item, IObjectCollection* collection) { @@ -46,7 +46,7 @@ bool AppendSeparator(IObjectCollection* collection) { if (SUCCEEDED(shell_link.CoCreateInstance(CLSID_ShellLink))) { CComQIPtr property_store(shell_link); if (base::win::SetBooleanValueForPropertyStore( - property_store, PKEY_AppUserModel_IsDestListSeparator, true)) + property_store, PKEY_AppUserModel_IsDestListSeparator, true)) return SUCCEEDED(collection->AddObject(shell_link)); } return false; @@ -56,8 +56,8 @@ bool AppendFile(const JumpListItem& item, IObjectCollection* collection) { DCHECK(collection); CComPtr file; - if (SUCCEEDED(SHCreateItemFromParsingName( - item.path.value().c_str(), NULL, IID_PPV_ARGS(&file)))) + if (SUCCEEDED(SHCreateItemFromParsingName(item.path.value().c_str(), NULL, + IID_PPV_ARGS(&file)))) return SUCCEEDED(collection->AddObject(file)); return false; @@ -68,8 +68,8 @@ bool GetShellItemFileName(IShellItem* shell_item, base::FilePath* file_name) { DCHECK(file_name); base::win::ScopedCoMem file_name_buffer; - if (SUCCEEDED(shell_item->GetDisplayName(SIGDN_FILESYSPATH, - &file_name_buffer))) { + if (SUCCEEDED( + shell_item->GetDisplayName(SIGDN_FILESYSPATH, &file_name_buffer))) { *file_name = base::FilePath(file_name_buffer.get()); return true; } @@ -88,19 +88,20 @@ bool ConvertShellLinkToJumpListItem(IShellLink* shell_link, CComQIPtr property_store = shell_link; base::win::ScopedPropVariant prop; - if (SUCCEEDED(property_store->GetValue(PKEY_Link_Arguments, prop.Receive())) - && (prop.get().vt == VT_LPWSTR)) { + if (SUCCEEDED( + property_store->GetValue(PKEY_Link_Arguments, prop.Receive())) && + (prop.get().vt == VT_LPWSTR)) { item->arguments = prop.get().pwszVal; } - if (SUCCEEDED(property_store->GetValue(PKEY_Title, prop.Receive())) - && (prop.get().vt == VT_LPWSTR)) { + if (SUCCEEDED(property_store->GetValue(PKEY_Title, prop.Receive())) && + (prop.get().vt == VT_LPWSTR)) { item->title = prop.get().pwszVal; } int icon_index; - if (SUCCEEDED(shell_link->GetIconLocation(path, arraysize(path), - &icon_index))) { + if (SUCCEEDED( + shell_link->GetIconLocation(path, arraysize(path), &icon_index))) { item->icon_path = base::FilePath(path); item->icon_index = icon_index; } @@ -219,7 +220,8 @@ JumpListResult JumpList::AppendCategory(const JumpListCategory& category) { if (AppendTask(item, collection)) ++appended_count; else - LOG(ERROR) << "Failed to append task '" << item.title << "' " + LOG(ERROR) << "Failed to append task '" << item.title + << "' " "to Jump List."; break; @@ -240,7 +242,8 @@ JumpListResult JumpList::AppendCategory(const JumpListCategory& category) { if (AppendFile(item, collection)) ++appended_count; else - LOG(ERROR) << "Failed to append '" << item.path.value() << "' " + LOG(ERROR) << "Failed to append '" << item.path.value() + << "' " "to Jump List."; break; } @@ -322,7 +325,7 @@ JumpListResult JumpList::AppendCategories( // Keep the first non-generic error code as only one can be returned from // the function (so try to make it the most useful one). if (((result == JumpListResult::SUCCESS) || - (result == JumpListResult::GENERIC_ERROR)) && + (result == JumpListResult::GENERIC_ERROR)) && (latestResult != JumpListResult::SUCCESS)) result = latestResult; } diff --git a/atom/browser/ui/win/jump_list.h b/atom/browser/ui/win/jump_list.h index c7660003ae7..fc4ab085fc0 100644 --- a/atom/browser/ui/win/jump_list.h +++ b/atom/browser/ui/win/jump_list.h @@ -98,7 +98,7 @@ class JumpList { JumpListResult AppendCategory(const JumpListCategory& category); // Appends categories to the custom Jump List. JumpListResult AppendCategories( - const std::vector& categories); + const std::vector& categories); private: base::string16 app_id_; diff --git a/atom/browser/ui/win/message_handler_delegate.cc b/atom/browser/ui/win/message_handler_delegate.cc index 791d1fd816d..d8b4a42ffac 100644 --- a/atom/browser/ui/win/message_handler_delegate.cc +++ b/atom/browser/ui/win/message_handler_delegate.cc @@ -6,8 +6,10 @@ namespace atom { -bool MessageHandlerDelegate::PreHandleMSG( - UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) { +bool MessageHandlerDelegate::PreHandleMSG(UINT message, + WPARAM w_param, + LPARAM l_param, + LRESULT* result) { return false; } diff --git a/atom/browser/ui/win/message_handler_delegate.h b/atom/browser/ui/win/message_handler_delegate.h index d8cfcf7fc43..1eb490a28d7 100644 --- a/atom/browser/ui/win/message_handler_delegate.h +++ b/atom/browser/ui/win/message_handler_delegate.h @@ -17,8 +17,10 @@ class MessageHandlerDelegate { // message was consumed by the delegate and should not be processed further // by the HWNDMessageHandler. In this case, |result| is returned. |result| is // not modified otherwise. - virtual bool PreHandleMSG( - UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result); + virtual bool PreHandleMSG(UINT message, + WPARAM w_param, + LPARAM l_param, + LRESULT* result); }; } // namespace atom diff --git a/atom/browser/ui/win/notify_icon.cc b/atom/browser/ui/win/notify_icon.cc index 84faba0aa2e..afd62f2f019 100644 --- a/atom/browser/ui/win/notify_icon.cc +++ b/atom/browser/ui/win/notify_icon.cc @@ -18,10 +18,7 @@ namespace atom { -NotifyIcon::NotifyIcon(NotifyIconHost* host, - UINT id, - HWND window, - UINT message) +NotifyIcon::NotifyIcon(NotifyIconHost* host, UINT id, HWND window, UINT message) : host_(host), icon_id_(id), window_(window), @@ -152,8 +149,8 @@ void NotifyIcon::PopUpContextMenu(const gfx::Point& pos, menu_runner_.reset(new views::MenuRunner( menu_model != nullptr ? menu_model : menu_model_, views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS)); - menu_runner_->RunMenuAt( - NULL, NULL, rect, views::MENU_ANCHOR_TOPLEFT, ui::MENU_SOURCE_MOUSE); + menu_runner_->RunMenuAt(NULL, NULL, rect, views::MENU_ANCHOR_TOPLEFT, + ui::MENU_SOURCE_MOUSE); } void NotifyIcon::SetContextMenu(AtomMenuModel* menu_model) { @@ -167,7 +164,7 @@ gfx::Rect NotifyIcon::GetBounds() { icon_id.hWnd = window_; icon_id.cbSize = sizeof(NOTIFYICONIDENTIFIER); - RECT rect = { 0 }; + RECT rect = {0}; Shell_NotifyIconGetRect(&icon_id, &rect); return display::win::ScreenWin::ScreenToDIPRect(window_, gfx::Rect(rect)); } diff --git a/atom/browser/ui/win/notify_icon_host.cc b/atom/browser/ui/win/notify_icon_host.cc index 9d4f3d0117c..d056062d0ec 100644 --- a/atom/browser/ui/win/notify_icon_host.cc +++ b/atom/browser/ui/win/notify_icon_host.cc @@ -48,17 +48,13 @@ int GetKeyboardModifers() { } // namespace NotifyIconHost::NotifyIconHost() - : next_icon_id_(1), - atom_(0), - instance_(NULL), - window_(NULL) { + : next_icon_id_(1), atom_(0), instance_(NULL), window_(NULL) { // Register our window class WNDCLASSEX window_class; base::win::InitializeWindowClass( kNotifyIconHostWindowClass, - &base::win::WrappedWindowProc, - 0, 0, 0, NULL, NULL, NULL, NULL, NULL, - &window_class); + &base::win::WrappedWindowProc, 0, 0, 0, + NULL, NULL, NULL, NULL, NULL, &window_class); instance_ = window_class.hInstance; atom_ = RegisterClassEx(&window_class); CHECK(atom_); @@ -71,8 +67,8 @@ NotifyIconHost::NotifyIconHost() // create a hidden WS_POPUP window instead of an HWND_MESSAGE window, because // only top-level windows such as popups can receive broadcast messages like // "TaskbarCreated". - window_ = CreateWindow(MAKEINTATOM(atom_), - 0, WS_POPUP, 0, 0, 0, 0, 0, 0, instance_, 0); + window_ = CreateWindow(MAKEINTATOM(atom_), 0, WS_POPUP, 0, 0, 0, 0, 0, 0, + instance_, 0); gfx::CheckWindowCreated(window_); gfx::SetWindowUserData(window_, this); } @@ -108,11 +104,11 @@ void NotifyIconHost::Remove(NotifyIcon* icon) { } LRESULT CALLBACK NotifyIconHost::WndProcStatic(HWND hwnd, - UINT message, - WPARAM wparam, - LPARAM lparam) { - NotifyIconHost* msg_wnd = reinterpret_cast( - GetWindowLongPtr(hwnd, GWLP_USERDATA)); + UINT message, + WPARAM wparam, + LPARAM lparam) { + NotifyIconHost* msg_wnd = + reinterpret_cast(GetWindowLongPtr(hwnd, GWLP_USERDATA)); if (msg_wnd) return msg_wnd->WndProc(hwnd, message, wparam, lparam); else @@ -120,9 +116,9 @@ LRESULT CALLBACK NotifyIconHost::WndProcStatic(HWND hwnd, } LRESULT CALLBACK NotifyIconHost::WndProc(HWND hwnd, - UINT message, - WPARAM wparam, - LPARAM lparam) { + UINT message, + WPARAM wparam, + LPARAM lparam) { if (message == taskbar_created_message_) { // We need to reset all of our icons because the taskbar went away. for (NotifyIcons::const_iterator i(notify_icons_.begin()); diff --git a/atom/browser/ui/win/notify_icon_host.h b/atom/browser/ui/win/notify_icon_host.h index 773b3112d47..76419a057fa 100644 --- a/atom/browser/ui/win/notify_icon_host.h +++ b/atom/browser/ui/win/notify_icon_host.h @@ -27,11 +27,15 @@ class NotifyIconHost { typedef std::vector NotifyIcons; // Static callback invoked when a message comes in to our messaging window. - static LRESULT CALLBACK - WndProcStatic(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); + static LRESULT CALLBACK WndProcStatic(HWND hwnd, + UINT message, + WPARAM wparam, + LPARAM lparam); - LRESULT CALLBACK - WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); + LRESULT CALLBACK WndProc(HWND hwnd, + UINT message, + WPARAM wparam, + LPARAM lparam); UINT NextIconId(); diff --git a/atom/browser/ui/win/taskbar_host.cc b/atom/browser/ui/win/taskbar_host.cc index 598f910c057..24d038a059c 100644 --- a/atom/browser/ui/win/taskbar_host.cc +++ b/atom/browser/ui/win/taskbar_host.cc @@ -19,7 +19,8 @@ namespace atom { namespace { -// From MSDN: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378460(v=vs.85).aspx#thumbbars +// From MSDN: +// https://msdn.microsoft.com/en-us/library/windows/desktop/dd378460(v=vs.85).aspx#thumbbars // The thumbnail toolbar has a maximum of seven buttons due to the limited room. const size_t kMaxButtonsCount = 7; @@ -49,14 +50,12 @@ bool GetThumbarButtonFlags(const std::vector& flags, } // namespace -TaskbarHost::TaskbarHost() : thumbar_buttons_added_(false) { -} +TaskbarHost::TaskbarHost() : thumbar_buttons_added_(false) {} -TaskbarHost::~TaskbarHost() { -} +TaskbarHost::~TaskbarHost() {} -bool TaskbarHost::SetThumbarButtons( - HWND window, const std::vector& buttons) { +bool TaskbarHost::SetThumbarButtons(HWND window, + const std::vector& buttons) { if (buttons.size() > kMaxButtonsCount || !InitializeTaskbar()) return false; @@ -128,8 +127,9 @@ void TaskbarHost::RestoreThumbarButtons(HWND window) { } } -bool TaskbarHost::SetProgressBar( - HWND window, double value, const NativeWindow::ProgressState state) { +bool TaskbarHost::SetProgressBar(HWND window, + double value, + const NativeWindow::ProgressState state) { if (!InitializeTaskbar()) return false; @@ -160,15 +160,16 @@ bool TaskbarHost::SetProgressBar( return success; } -bool TaskbarHost::SetOverlayIcon( - HWND window, const gfx::Image& overlay, const std::string& text) { +bool TaskbarHost::SetOverlayIcon(HWND window, + const gfx::Image& overlay, + const std::string& text) { if (!InitializeTaskbar()) return false; base::win::ScopedHICON icon( IconUtil::CreateHICONFromSkBitmap(overlay.AsBitmap())); - return SUCCEEDED(taskbar_->SetOverlayIcon( - window, icon.get(), base::UTF8ToUTF16(text).c_str())); + return SUCCEEDED(taskbar_->SetOverlayIcon(window, icon.get(), + base::UTF8ToUTF16(text).c_str())); } bool TaskbarHost::SetThumbnailClip(HWND window, const gfx::Rect& region) { @@ -178,14 +179,13 @@ bool TaskbarHost::SetThumbnailClip(HWND window, const gfx::Rect& region) { if (region.IsEmpty()) { return SUCCEEDED(taskbar_->SetThumbnailClip(window, NULL)); } else { - RECT rect = display::win::ScreenWin::DIPToScreenRect(window, region) - .ToRECT(); + RECT rect = + display::win::ScreenWin::DIPToScreenRect(window, region).ToRECT(); return SUCCEEDED(taskbar_->SetThumbnailClip(window, &rect)); } } -bool TaskbarHost::SetThumbnailToolTip( - HWND window, const std::string& tooltip) { +bool TaskbarHost::SetThumbnailToolTip(HWND window, const std::string& tooltip) { if (!InitializeTaskbar()) return false; diff --git a/atom/browser/ui/win/taskbar_host.h b/atom/browser/ui/win/taskbar_host.h index e5acaa78758..e6b5a3e46f8 100644 --- a/atom/browser/ui/win/taskbar_host.h +++ b/atom/browser/ui/win/taskbar_host.h @@ -32,18 +32,20 @@ class TaskbarHost { virtual ~TaskbarHost(); // Add or update the buttons in thumbar. - bool SetThumbarButtons( - HWND window, const std::vector& buttons); + bool SetThumbarButtons(HWND window, + const std::vector& buttons); void RestoreThumbarButtons(HWND window); // Set the progress state in taskbar. - bool SetProgressBar( - HWND window, double value, const NativeWindow::ProgressState state); + bool SetProgressBar(HWND window, + double value, + const NativeWindow::ProgressState state); // Set the overlay icon in taskbar. - bool SetOverlayIcon( - HWND window, const gfx::Image& overlay, const std::string& text); + bool SetOverlayIcon(HWND window, + const gfx::Image& overlay, + const std::string& text); // Set the region of the window to show as a thumbnail in taskbar. bool SetThumbnailClip(HWND window, const gfx::Rect& region); diff --git a/atom/browser/ui/x/event_disabler.cc b/atom/browser/ui/x/event_disabler.cc index 6d0e4cfeb04..249ded7af26 100644 --- a/atom/browser/ui/x/event_disabler.cc +++ b/atom/browser/ui/x/event_disabler.cc @@ -6,11 +6,9 @@ namespace atom { -EventDisabler::EventDisabler() { -} +EventDisabler::EventDisabler() {} -EventDisabler::~EventDisabler() { -} +EventDisabler::~EventDisabler() {} ui::EventRewriteStatus EventDisabler::RewriteEvent( const ui::Event& event, diff --git a/atom/browser/ui/x/window_state_watcher.cc b/atom/browser/ui/x/window_state_watcher.cc index 414cd85e82b..e0fbf2a3abc 100644 --- a/atom/browser/ui/x/window_state_watcher.cc +++ b/atom/browser/ui/x/window_state_watcher.cc @@ -14,8 +14,8 @@ namespace atom { namespace { const char* kAtomsToCache[] = { - "_NET_WM_STATE", - NULL, + "_NET_WM_STATE", + NULL, }; } // namespace @@ -71,8 +71,7 @@ void WindowStateWatcher::DidProcessEvent(const ui::PlatformEvent& event) { bool WindowStateWatcher::IsWindowStateEvent(const ui::PlatformEvent& event) { ::Atom changed_atom = event->xproperty.atom; return (changed_atom == gfx::GetAtom("_NET_WM_STATE") && - event->type == PropertyNotify && - event->xproperty.window == widget_); + event->type == PropertyNotify && event->xproperty.window == widget_); } } // namespace atom diff --git a/atom/browser/ui/x/x_window_utils.cc b/atom/browser/ui/x/x_window_utils.cc index 275c7858924..0703e6ac2f3 100644 --- a/atom/browser/ui/x/x_window_utils.cc +++ b/atom/browser/ui/x/x_window_utils.cc @@ -35,8 +35,7 @@ void SetWMSpecState(::Window xwindow, bool enabled, ::Atom state) { XDisplay* xdisplay = gfx::GetXDisplay(); XSendEvent(xdisplay, DefaultRootWindow(xdisplay), False, - SubstructureRedirectMask | SubstructureNotifyMask, - &xclient); + SubstructureRedirectMask | SubstructureNotifyMask, &xclient); } void SetWindowType(::Window xwindow, const std::string& type) { @@ -45,8 +44,7 @@ void SetWindowType(::Window xwindow, const std::string& type) { ::Atom window_type = XInternAtom( xdisplay, (type_prefix + base::ToUpperASCII(type)).c_str(), False); XChangeProperty(xdisplay, xwindow, - XInternAtom(xdisplay, "_NET_WM_WINDOW_TYPE", False), - XA_ATOM, + XInternAtom(xdisplay, "_NET_WM_WINDOW_TYPE", False), XA_ATOM, 32, PropModeReplace, reinterpret_cast(&window_type), 1); } diff --git a/atom/browser/ui/x/x_window_utils.h b/atom/browser/ui/x/x_window_utils.h index 16f3ddac6cc..78279c667fa 100644 --- a/atom/browser/ui/x/x_window_utils.h +++ b/atom/browser/ui/x/x_window_utils.h @@ -5,9 +5,9 @@ #ifndef ATOM_BROWSER_UI_X_X_WINDOW_UTILS_H_ #define ATOM_BROWSER_UI_X_X_WINDOW_UTILS_H_ +#include #include #include -#include #include diff --git a/atom/browser/web_contents_permission_helper.cc b/atom/browser/web_contents_permission_helper.cc index 2d85009c79a..dee2e6c80da 100644 --- a/atom/browser/web_contents_permission_helper.cc +++ b/atom/browser/web_contents_permission_helper.cc @@ -18,10 +18,9 @@ namespace atom { namespace { -void MediaAccessAllowed( - const content::MediaStreamRequest& request, - const content::MediaResponseCallback& callback, - bool allowed) { +void MediaAccessAllowed(const content::MediaStreamRequest& request, + const content::MediaResponseCallback& callback, + bool allowed) { brightray::MediaStreamDevicesController controller(request, callback); if (allowed) controller.TakeAction(); @@ -46,11 +45,9 @@ void OnPermissionResponse(const base::Callback& callback, WebContentsPermissionHelper::WebContentsPermissionHelper( content::WebContents* web_contents) - : web_contents_(web_contents) { -} + : web_contents_(web_contents) {} -WebContentsPermissionHelper::~WebContentsPermissionHelper() { -} +WebContentsPermissionHelper::~WebContentsPermissionHelper() {} void WebContentsPermissionHelper::RequestPermission( content::PermissionType permission, diff --git a/atom/browser/web_contents_permission_helper.h b/atom/browser/web_contents_permission_helper.h index 02879c68e36..322e0972fde 100644 --- a/atom/browser/web_contents_permission_helper.h +++ b/atom/browser/web_contents_permission_helper.h @@ -23,28 +23,25 @@ class WebContentsPermissionHelper OPEN_EXTERNAL, }; - void RequestFullscreenPermission( - const base::Callback& callback); + void RequestFullscreenPermission(const base::Callback& callback); void RequestMediaAccessPermission( const content::MediaStreamRequest& request, const content::MediaResponseCallback& callback); void RequestWebNotificationPermission( const base::Callback& callback); void RequestPointerLockPermission(bool user_gesture); - void RequestOpenExternalPermission( - const base::Callback& callback, - bool user_gesture, - const GURL& url); + void RequestOpenExternalPermission(const base::Callback& callback, + bool user_gesture, + const GURL& url); private: explicit WebContentsPermissionHelper(content::WebContents* web_contents); friend class content::WebContentsUserData; - void RequestPermission( - content::PermissionType permission, - const base::Callback& callback, - bool user_gesture = false, - const base::DictionaryValue* details = nullptr); + void RequestPermission(content::PermissionType permission, + const base::Callback& callback, + bool user_gesture = false, + const base::DictionaryValue* details = nullptr); content::WebContents* web_contents_; diff --git a/atom/browser/web_contents_preferences.cc b/atom/browser/web_contents_preferences.cc index 74687af992e..cbaee6aaf7c 100644 --- a/atom/browser/web_contents_preferences.cc +++ b/atom/browser/web_contents_preferences.cc @@ -73,22 +73,22 @@ WebContentsPreferences::WebContentsPreferences( } else { SetDefaultBoolIfUndefined("allowRunningInsecureContent", false); } - #if defined(OS_MACOSX) +#if defined(OS_MACOSX) SetDefaultBoolIfUndefined(options::kScrollBounce, false); - #endif +#endif SetDefaultBoolIfUndefined("offscreen", false); last_dict_ = std::move(*dict_.CreateDeepCopy()); } WebContentsPreferences::~WebContentsPreferences() { - instances_.erase( - std::remove(instances_.begin(), instances_.end(), this), - instances_.end()); + instances_.erase(std::remove(instances_.begin(), instances_.end(), this), + instances_.end()); } bool WebContentsPreferences::SetDefaultBoolIfUndefined( - const base::StringPiece& key, bool val) { + const base::StringPiece& key, + bool val) { bool existing; if (!dict_.GetBoolean(key, &existing)) { dict_.SetBoolean(key, val); @@ -186,8 +186,7 @@ void WebContentsPreferences::AppendCommandLineSwitches( // Custom args for renderer process base::Value* customArgs; - if (dict_.Get(options::kCustomArgs, &customArgs) && - customArgs->is_list()) { + if (dict_.Get(options::kCustomArgs, &customArgs) && customArgs->is_list()) { for (const base::Value& customArg : customArgs->GetList()) { if (customArg.is_string()) command_line->AppendArg(customArg.GetString()); diff --git a/atom/browser/web_contents_zoom_controller.cc b/atom/browser/web_contents_zoom_controller.cc index 82618e3696b..afb5b78bfaf 100644 --- a/atom/browser/web_contents_zoom_controller.cc +++ b/atom/browser/web_contents_zoom_controller.cc @@ -71,8 +71,7 @@ void WebContentsZoomController::SetZoomLevel(double level) { content::HostZoomMap::GetForWebContents(web_contents()); if (zoom_mode_ == ZOOM_MODE_ISOLATED || zoom_map->UsesTemporaryZoomLevel(render_process_id, render_view_id)) { - zoom_map->SetTemporaryZoomLevel( - render_process_id, render_view_id, level); + zoom_map->SetTemporaryZoomLevel(render_process_id, render_view_id, level); // Notify observers of zoom level changes. for (Observer& observer : observers_) observer.OnZoomLevelChanged(web_contents(), level, true); @@ -116,7 +115,6 @@ bool WebContentsZoomController::UsesTemporaryZoomLevel() { render_view_id); } - void WebContentsZoomController::SetZoomMode(ZoomMode new_mode) { if (new_mode == zoom_mode_) return; @@ -169,7 +167,7 @@ void WebContentsZoomController::SetZoomMode(ZoomMode new_mode) { // manually. for (Observer& observer : observers_) observer.OnZoomLevelChanged(web_contents(), original_zoom_level, - false); + false); } break; } @@ -178,22 +176,22 @@ void WebContentsZoomController::SetZoomMode(ZoomMode new_mode) { // page needs to be resized to the default zoom. While in manual mode, // the zoom level is handled independently. if (zoom_mode_ != ZOOM_MODE_DISABLED) { - zoom_map->SetTemporaryZoomLevel( - render_process_id, render_view_id, GetDefaultZoomLevel()); + zoom_map->SetTemporaryZoomLevel(render_process_id, render_view_id, + GetDefaultZoomLevel()); zoom_level_ = original_zoom_level; } else { // When we don't call any HostZoomMap set functions, we send the event // manually. for (Observer& observer : observers_) observer.OnZoomLevelChanged(web_contents(), original_zoom_level, - false); + false); } break; } case ZOOM_MODE_DISABLED: { // The page needs to be zoomed back to default before disabling the zoom - zoom_map->SetTemporaryZoomLevel( - render_process_id, render_view_id, GetDefaultZoomLevel()); + zoom_map->SetTemporaryZoomLevel(render_process_id, render_view_id, + GetDefaultZoomLevel()); break; } } @@ -201,7 +199,6 @@ void WebContentsZoomController::SetZoomMode(ZoomMode new_mode) { zoom_mode_ = new_mode; } - void WebContentsZoomController::ResetZoomModeOnNavigationIfNeeded( const GURL& url) { if (zoom_mode_ != ZOOM_MODE_ISOLATED && zoom_mode_ != ZOOM_MODE_MANUAL) @@ -216,8 +213,7 @@ void WebContentsZoomController::ResetZoomModeOnNavigationIfNeeded( double new_zoom_level = zoom_map->GetZoomLevelForHostAndScheme( url.scheme(), net::GetHostOrSpecFromURL(url)); for (Observer& observer : observers_) - observer.OnZoomLevelChanged(web_contents(), new_zoom_level, - false); + observer.OnZoomLevelChanged(web_contents(), new_zoom_level, false); zoom_map->ClearTemporaryZoomLevel(render_process_id, render_view_id); zoom_mode_ = ZOOM_MODE_DEFAULT; } diff --git a/atom/browser/web_dialog_helper.cc b/atom/browser/web_dialog_helper.cc index 878b4176a9d..ffe0bd82de3 100644 --- a/atom/browser/web_dialog_helper.cc +++ b/atom/browser/web_dialog_helper.cc @@ -33,8 +33,8 @@ class FileSelectHelper : public base::RefCounted, FileSelectHelper(content::RenderFrameHost* render_frame_host, const content::FileChooserParams::Mode& mode) : render_frame_host_(render_frame_host), mode_(mode) { - auto web_contents = content::WebContents::FromRenderFrameHost( - render_frame_host); + auto web_contents = + content::WebContents::FromRenderFrameHost(render_frame_host); content::WebContentsObserver::Observe(web_contents); } @@ -54,7 +54,8 @@ class FileSelectHelper : public base::RefCounted, ~FileSelectHelper() override {} #if defined(MAS_BUILD) - void OnOpenDialogDone(bool result, const std::vector& paths, + void OnOpenDialogDone(bool result, + const std::vector& paths, const std::vector& bookmarks) #else void OnOpenDialogDone(bool result, const std::vector& paths) @@ -80,7 +81,8 @@ class FileSelectHelper : public base::RefCounted, } #if defined(MAS_BUILD) - void OnSaveDialogDone(bool result, const base::FilePath& path, + void OnSaveDialogDone(bool result, + const base::FilePath& path, const std::string& bookmark) #else void OnSaveDialogDone(bool result, const base::FilePath& path) @@ -116,9 +118,7 @@ class FileSelectHelper : public base::RefCounted, } // content::WebContentsObserver: - void WebContentsDestroyed() override { - render_frame_host_ = nullptr; - } + void WebContentsDestroyed() override { render_frame_host_ = nullptr; } content::RenderFrameHost* render_frame_host_; content::FileChooserParams::Mode mode_; @@ -142,8 +142,8 @@ file_dialog::Filters GetFileTypesFromAcceptType( if (ascii_type[0] == '.') { // If the type starts with a period it is assumed to be a file extension, // like `.txt`, // so we just have to add it to the list. - base::FilePath::StringType extension( - ascii_type.begin(), ascii_type.end()); + base::FilePath::StringType extension(ascii_type.begin(), + ascii_type.end()); // Skip the first character. extensions.push_back(extension.substr(1)); } else { @@ -195,14 +195,9 @@ file_dialog::Filters GetFileTypesFromAcceptType( namespace atom { WebDialogHelper::WebDialogHelper(NativeWindow* window, bool offscreen) - : window_(window), - offscreen_(offscreen), - weak_factory_(this) { -} - -WebDialogHelper::~WebDialogHelper() { -} + : window_(window), offscreen_(offscreen), weak_factory_(this) {} +WebDialogHelper::~WebDialogHelper() {} void WebDialogHelper::RunFileChooser( content::RenderFrameHost* render_frame_host, @@ -237,8 +232,9 @@ void WebDialogHelper::RunFileChooser( auto* browser_context = static_cast( render_frame_host->GetProcess()->GetBrowserContext()); - settings.default_path = browser_context->prefs()->GetFilePath( - prefs::kSelectFileLastDirectory).Append(params.default_file_name); + settings.default_path = browser_context->prefs() + ->GetFilePath(prefs::kSelectFileLastDirectory) + .Append(params.default_file_name); settings.properties = flags; file_select_helper->ShowOpenDialog(settings); } @@ -247,8 +243,7 @@ void WebDialogHelper::RunFileChooser( void WebDialogHelper::EnumerateDirectory(content::WebContents* web_contents, int request_id, const base::FilePath& dir) { - int types = base::FileEnumerator::FILES | - base::FileEnumerator::DIRECTORIES | + int types = base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES | base::FileEnumerator::INCLUDE_DOT_DOT; base::FileEnumerator file_enum(dir, false, types); @@ -257,8 +252,8 @@ void WebDialogHelper::EnumerateDirectory(content::WebContents* web_contents, while (!(path = file_enum.Next()).empty()) paths.push_back(path); - web_contents->GetRenderViewHost()->DirectoryEnumerationFinished( - request_id, paths); + web_contents->GetRenderViewHost()->DirectoryEnumerationFinished(request_id, + paths); } } // namespace atom diff --git a/atom/browser/web_dialog_helper.h b/atom/browser/web_dialog_helper.h index 9165b596139..e08a1a915bc 100644 --- a/atom/browser/web_dialog_helper.h +++ b/atom/browser/web_dialog_helper.h @@ -15,7 +15,7 @@ namespace content { struct FileChooserParams; class RenderFrameHost; class WebContents; -} +} // namespace content namespace atom { diff --git a/atom/browser/web_view_guest_delegate.cc b/atom/browser/web_view_guest_delegate.cc index e2dd6e14df5..74e574f3e86 100644 --- a/atom/browser/web_view_guest_delegate.cc +++ b/atom/browser/web_view_guest_delegate.cc @@ -31,8 +31,7 @@ WebViewGuestDelegate::WebViewGuestDelegate() attached_(false), api_web_contents_(nullptr) {} -WebViewGuestDelegate::~WebViewGuestDelegate() { -} +WebViewGuestDelegate::~WebViewGuestDelegate() {} void WebViewGuestDelegate::Initialize(api::WebContents* api_web_contents) { api_web_contents_ = api_web_contents; @@ -168,9 +167,9 @@ void WebViewGuestDelegate::OnZoomLevelChanged( } void WebViewGuestDelegate::GuestSizeChangedDueToAutoSize( - const gfx::Size& old_size, const gfx::Size& new_size) { - api_web_contents_->Emit("size-changed", - old_size.width(), old_size.height(), + const gfx::Size& old_size, + const gfx::Size& new_size) { + api_web_contents_->Emit("size-changed", old_size.width(), old_size.height(), new_size.width(), new_size.height()); } @@ -178,7 +177,7 @@ gfx::Size WebViewGuestDelegate::GetDefaultSize() const { if (is_full_page_plugin_) { // Full page plugins default to the size of the owner's viewport. return embedder_web_contents_->GetRenderWidgetHostView() - ->GetVisibleViewportSize(); + ->GetVisibleViewportSize(); } else { return gfx::Size(kDefaultWidth, kDefaultHeight); } diff --git a/atom/browser/web_view_guest_delegate.h b/atom/browser/web_view_guest_delegate.h index 166a8130c46..3425c055cc9 100644 --- a/atom/browser/web_view_guest_delegate.h +++ b/atom/browser/web_view_guest_delegate.h @@ -69,7 +69,7 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate, content::RenderWidgetHost* GetOwnerRenderWidgetHost() override; content::SiteInstance* GetOwnerSiteInstance() override; content::WebContents* CreateNewGuestWindow( - const content::WebContents::CreateParams& create_params) override; + const content::WebContents::CreateParams& create_params) override; // WebContentsZoomController::Observer: void OnZoomLevelChanged(content::WebContents* web_contents, diff --git a/atom/browser/web_view_manager.cc b/atom/browser/web_view_manager.cc index ce63d6e4412..8ac674e9868 100644 --- a/atom/browser/web_view_manager.cc +++ b/atom/browser/web_view_manager.cc @@ -11,17 +11,15 @@ namespace atom { -WebViewManager::WebViewManager() { -} +WebViewManager::WebViewManager() {} -WebViewManager::~WebViewManager() { -} +WebViewManager::~WebViewManager() {} void WebViewManager::AddGuest(int guest_instance_id, int element_instance_id, content::WebContents* embedder, content::WebContents* web_contents) { - web_contents_embedder_map_[guest_instance_id] = { web_contents, embedder }; + web_contents_embedder_map_[guest_instance_id] = {web_contents, embedder}; // Map the element in embedder to guest. int owner_process_id = embedder->GetMainFrame()->GetProcess()->GetID(); diff --git a/atom/browser/web_view_manager.h b/atom/browser/web_view_manager.h index eb2ba8ad42c..1adc27678da 100644 --- a/atom/browser/web_view_manager.h +++ b/atom/browser/web_view_manager.h @@ -56,7 +56,7 @@ class WebViewManager : public content::BrowserPluginGuestManager { bool operator==(const ElementInstanceKey& other) const { return (embedder_process_id == other.embedder_process_id) && - (element_instance_id == other.element_instance_id); + (element_instance_id == other.element_instance_id); } }; // (embedder_process_id, element_instance_id) => guest_instance_id diff --git a/atom/browser/window_list.cc b/atom/browser/window_list.cc index baef11f6561..72456838d83 100644 --- a/atom/browser/window_list.cc +++ b/atom/browser/window_list.cc @@ -96,10 +96,8 @@ void WindowList::DestroyAllWindows() { window->CloseImmediately(); // e.g. Destroy() } -WindowList::WindowList() { -} +WindowList::WindowList() {} -WindowList::~WindowList() { -} +WindowList::~WindowList() {} } // namespace atom diff --git a/atom/common/api/atom_api_asar.cc b/atom/common/api/atom_api_asar.cc index 815940aae43..a6be35e9502 100644 --- a/atom/common/api/atom_api_asar.cc +++ b/atom/common/api/atom_api_asar.cc @@ -22,15 +22,15 @@ namespace { class Archive : public mate::Wrappable { public: static v8::Local Create(v8::Isolate* isolate, - const base::FilePath& path) { + const base::FilePath& path) { std::unique_ptr archive(new asar::Archive(path)); if (!archive->Init()) return v8::False(isolate); return (new Archive(isolate, std::move(archive)))->GetWrapper(); } - static void BuildPrototype( - v8::Isolate* isolate, v8::Local prototype) { + static void BuildPrototype(v8::Isolate* isolate, + v8::Local prototype) { prototype->SetClassName(mate::StringToV8(isolate, "Archive")); mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) .SetProperty("path", &Archive::GetPath) @@ -50,13 +50,11 @@ class Archive : public mate::Wrappable { } // Returns the path of the file. - base::FilePath GetPath() { - return archive_->path(); - } + base::FilePath GetPath() { return archive_->path(); } // Reads the offset and size of file. v8::Local GetFileInfo(v8::Isolate* isolate, - const base::FilePath& path) { + const base::FilePath& path) { asar::Archive::FileInfo info; if (!archive_ || !archive_->GetFileInfo(path, &info)) return v8::False(isolate); @@ -68,8 +66,7 @@ class Archive : public mate::Wrappable { } // Returns a fake result of fs.stat(path). - v8::Local Stat(v8::Isolate* isolate, - const base::FilePath& path) { + v8::Local Stat(v8::Isolate* isolate, const base::FilePath& path) { asar::Archive::Stats stats; if (!archive_ || !archive_->Stat(path, &stats)) return v8::False(isolate); @@ -84,7 +81,7 @@ class Archive : public mate::Wrappable { // Returns all files under a directory. v8::Local Readdir(v8::Isolate* isolate, - const base::FilePath& path) { + const base::FilePath& path) { std::vector files; if (!archive_ || !archive_->Readdir(path, &files)) return v8::False(isolate); @@ -93,7 +90,7 @@ class Archive : public mate::Wrappable { // Returns the path of file with symbol link resolved. v8::Local Realpath(v8::Isolate* isolate, - const base::FilePath& path) { + const base::FilePath& path) { base::FilePath realpath; if (!archive_ || !archive_->Realpath(path, &realpath)) return v8::False(isolate); @@ -102,7 +99,7 @@ class Archive : public mate::Wrappable { // Copy the file out into a temporary file and returns the new path. v8::Local CopyFileOut(v8::Isolate* isolate, - const base::FilePath& path) { + const base::FilePath& path) { base::FilePath new_path; if (!archive_ || !archive_->CopyFileOut(path, &new_path)) return v8::False(isolate); @@ -117,9 +114,7 @@ class Archive : public mate::Wrappable { } // Free the resources used by archive. - void Destroy() { - archive_.reset(); - } + void Destroy() { archive_.reset(); } private: std::unique_ptr archive_; @@ -138,14 +133,18 @@ void InitAsarSupport(v8::Isolate* isolate, // Initialize asar support. if (result->IsFunction()) { v8::Local args[] = { - process, require, node::asar_value.ToStringChecked(isolate), + process, + require, + node::asar_value.ToStringChecked(isolate), }; result.As()->Call(result, 3, args); } } -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { mate::Dictionary dict(context->GetIsolate(), exports); dict.SetMethod("createArchive", &Archive::Create); dict.SetMethod("initAsarSupport", &InitAsarSupport); diff --git a/atom/common/api/atom_api_crash_reporter.cc b/atom/common/api/atom_api_crash_reporter.cc index 78ef525f911..4aa48085d4d 100644 --- a/atom/common/api/atom_api_crash_reporter.cc +++ b/atom/common/api/atom_api_crash_reporter.cc @@ -16,12 +16,13 @@ using crash_reporter::CrashReporter; namespace mate { -template<> +template <> struct Converter { - static v8::Local ToV8(v8::Isolate* isolate, + static v8::Local ToV8( + v8::Isolate* isolate, const CrashReporter::UploadReportResult& reports) { mate::Dictionary dict(isolate, v8::Object::New(isolate)); - dict.Set("date", v8::Date::New(isolate, reports.first*1000.0)); + dict.Set("date", v8::Date::New(isolate, reports.first * 1000.0)); dict.Set("id", reports.second); return dict.GetHandle(); } @@ -43,8 +44,10 @@ std::map GetParameters() { return CrashReporter::GetInstance()->GetParameters(); } -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { mate::Dictionary dict(context->GetIsolate(), exports); auto reporter = base::Unretained(CrashReporter::GetInstance()); dict.SetMethod("start", base::Bind(&CrashReporter::Start, reporter)); diff --git a/atom/common/api/atom_api_key_weak_map.h b/atom/common/api/atom_api_key_weak_map.h index b8babe151a8..14c249e2198 100644 --- a/atom/common/api/atom_api_key_weak_map.h +++ b/atom/common/api/atom_api_key_weak_map.h @@ -14,7 +14,7 @@ namespace atom { namespace api { -template +template class KeyWeakMap : public mate::Wrappable> { public: static mate::Handle> Create(v8::Isolate* isolate) { @@ -47,13 +47,9 @@ class KeyWeakMap : public mate::Wrappable> { return key_weak_map_.Get(isolate, key).ToLocalChecked(); } - bool Has(const K& key) { - return key_weak_map_.Has(key); - } + bool Has(const K& key) { return key_weak_map_.Has(key); } - void Remove(const K& key) { - key_weak_map_.Remove(key); - } + void Remove(const K& key) { key_weak_map_.Remove(key); } atom::KeyWeakMap key_weak_map_; diff --git a/atom/common/api/atom_api_native_image.cc b/atom/common/api/atom_api_native_image.cc index 79d34017a2c..b52b438ae1a 100644 --- a/atom/common/api/atom_api_native_image.cc +++ b/atom/common/api/atom_api_native_image.cc @@ -50,18 +50,10 @@ struct ScaleFactorPair { }; ScaleFactorPair kScaleFactorPairs[] = { - // The "@2x" is put as first one to make scale matching faster. - { "@2x" , 2.0f }, - { "@3x" , 3.0f }, - { "@1x" , 1.0f }, - { "@4x" , 4.0f }, - { "@5x" , 5.0f }, - { "@1.25x" , 1.25f }, - { "@1.33x" , 1.33f }, - { "@1.4x" , 1.4f }, - { "@1.5x" , 1.5f }, - { "@1.8x" , 1.8f }, - { "@2.5x" , 2.5f }, + // The "@2x" is put as first one to make scale matching faster. + {"@2x", 2.0f}, {"@3x", 3.0f}, {"@1x", 1.0f}, {"@4x", 4.0f}, + {"@5x", 5.0f}, {"@1.25x", 1.25f}, {"@1.33x", 1.33f}, {"@1.4x", 1.4f}, + {"@1.5x", 1.5f}, {"@1.8x", 1.8f}, {"@2.5x", 2.5f}, }; float GetScaleFactorFromPath(const base::FilePath& path) { @@ -117,7 +109,7 @@ bool AddImageSkiaRep(gfx::ImageSkia* image, decoded.reset(new SkBitmap); decoded->allocN32Pixels(width, height, false); decoded->setPixels( - const_cast(reinterpret_cast(data))); + const_cast(reinterpret_cast(data))); } else { return false; } @@ -154,9 +146,8 @@ bool PopulateImageSkiaRepsFromPath(gfx::ImageSkia* image, succeed |= AddImageSkiaRep(image, path, 1.0f); for (const ScaleFactorPair& pair : kScaleFactorPairs) - succeed |= AddImageSkiaRep(image, - path.InsertBeforeExtensionASCII(pair.name), - pair.scale); + succeed |= AddImageSkiaRep( + image, path.InsertBeforeExtensionASCII(pair.name), pair.scale); return succeed; } @@ -195,9 +186,9 @@ base::win::ScopedHICON ReadICOFromPath(int size, const base::FilePath& path) { } // Load the icon from file. - return base::win::ScopedHICON(static_cast( - LoadImage(NULL, image_path.value().c_str(), IMAGE_ICON, size, size, - LR_LOADFROMFILE))); + return base::win::ScopedHICON( + static_cast(LoadImage(NULL, image_path.value().c_str(), IMAGE_ICON, + size, size, LR_LOADFROMFILE))); } bool ReadImageSkiaFromICO(gfx::ImageSkia* image, HICON icon) { @@ -211,8 +202,7 @@ bool ReadImageSkiaFromICO(gfx::ImageSkia* image, HICON icon) { } #endif -void Noop(char*, void*) { -} +void Noop(char*, void*) {} } // namespace @@ -221,7 +211,7 @@ NativeImage::NativeImage(v8::Isolate* isolate, const gfx::Image& image) Init(isolate); if (image_.HasRepresentation(gfx::Image::kImageRepSkia)) { isolate->AdjustAmountOfExternalAllocatedMemory( - image_.ToImageSkia()->bitmap()->computeByteSize()); + image_.ToImageSkia()->bitmap()->computeByteSize()); } } @@ -235,15 +225,15 @@ NativeImage::NativeImage(v8::Isolate* isolate, const base::FilePath& hicon_path) Init(isolate); if (image_.HasRepresentation(gfx::Image::kImageRepSkia)) { isolate->AdjustAmountOfExternalAllocatedMemory( - image_.ToImageSkia()->bitmap()->computeByteSize()); + image_.ToImageSkia()->bitmap()->computeByteSize()); } } #endif NativeImage::~NativeImage() { if (image_.HasRepresentation(gfx::Image::kImageRepSkia)) { - isolate()->AdjustAmountOfExternalAllocatedMemory( - -static_cast(image_.ToImageSkia()->bitmap()->computeByteSize())); + isolate()->AdjustAmountOfExternalAllocatedMemory(-static_cast( + image_.ToImageSkia()->bitmap()->computeByteSize())); } } @@ -262,8 +252,8 @@ HICON NativeImage::GetHICON(int size) { // Then convert the image to ICO. if (image_.IsEmpty()) return NULL; - hicons_[size] = std::move( - IconUtil::CreateHICONFromSkBitmap(image_.AsBitmap())); + hicons_[size] = + std::move(IconUtil::CreateHICONFromSkBitmap(image_.AsBitmap())); return hicons_[size].get(); } #endif @@ -300,7 +290,8 @@ v8::Local NativeImage::ToBitmap(mate::Arguments* args) { return node::Buffer::New(args->isolate(), 0).ToLocalChecked(); return node::Buffer::Copy(args->isolate(), reinterpret_cast(ref->pixels()), - bitmap.computeByteSize()).ToLocalChecked(); + bitmap.computeByteSize()) + .ToLocalChecked(); } v8::Local NativeImage::ToJPEG(v8::Isolate* isolate, int quality) { @@ -308,10 +299,10 @@ v8::Local NativeImage::ToJPEG(v8::Isolate* isolate, int quality) { gfx::JPEG1xEncodedDataFromImage(image_, quality, &output); if (output.empty()) return node::Buffer::New(isolate, 0).ToLocalChecked(); - return node::Buffer::Copy( - isolate, - reinterpret_cast(&output.front()), - output.size()).ToLocalChecked(); + return node::Buffer::Copy(isolate, + reinterpret_cast(&output.front()), + output.size()) + .ToLocalChecked(); } std::string NativeImage::ToDataURL(mate::Arguments* args) { @@ -338,21 +329,20 @@ v8::Local NativeImage::GetBitmap(mate::Arguments* args) { return node::Buffer::New(args->isolate(), 0).ToLocalChecked(); return node::Buffer::New(args->isolate(), reinterpret_cast(ref->pixels()), - bitmap.computeByteSize(), - &Noop, - nullptr).ToLocalChecked(); + bitmap.computeByteSize(), &Noop, nullptr) + .ToLocalChecked(); } v8::Local NativeImage::GetNativeHandle(v8::Isolate* isolate, mate::Arguments* args) { #if defined(OS_MACOSX) - if (IsEmpty()) return node::Buffer::New(isolate, 0).ToLocalChecked(); + if (IsEmpty()) + return node::Buffer::New(isolate, 0).ToLocalChecked(); NSImage* ptr = image_.AsNSImage(); - return node::Buffer::Copy( - isolate, - reinterpret_cast(ptr), - sizeof(void*)).ToLocalChecked(); + return node::Buffer::Copy(isolate, reinterpret_cast(ptr), + sizeof(void*)) + .ToLocalChecked(); #else args->ThrowError("Not implemented"); return v8::Undefined(isolate); @@ -376,7 +366,8 @@ float NativeImage::GetAspectRatio() { } mate::Handle NativeImage::Resize( - v8::Isolate* isolate, const base::DictionaryValue& options) { + v8::Isolate* isolate, + const base::DictionaryValue& options) { gfx::Size size = GetSize(); int width = size.width(); int height = size.height(); @@ -411,8 +402,8 @@ mate::Handle NativeImage::Resize( mate::Handle NativeImage::Crop(v8::Isolate* isolate, const gfx::Rect& rect) { - gfx::ImageSkia cropped = gfx::ImageSkiaOperations::ExtractSubset( - image_.AsImageSkia(), rect); + gfx::ImageSkia cropped = + gfx::ImageSkiaOperations::ExtractSubset(image_.AsImageSkia(), rect); return mate::CreateHandle(isolate, new NativeImage(isolate, gfx::Image(cropped))); } @@ -434,18 +425,15 @@ void NativeImage::AddRepresentation(const mate::Dictionary& options) { AddImageSkiaRep( &image_skia, reinterpret_cast(node::Buffer::Data(buffer)), - node::Buffer::Length(buffer), - width, height, scale_factor); + node::Buffer::Length(buffer), width, height, scale_factor); skia_rep_added = true; } else if (options.Get("dataURL", &url)) { std::string mime_type, charset, data; if (net::DataURL::Parse(url, &mime_type, &charset, &data)) { if (mime_type == "image/png" || mime_type == "image/jpeg") { - AddImageSkiaRep( - &image_skia, - reinterpret_cast(data.c_str()), - data.size(), - width, height, scale_factor); + AddImageSkiaRep(&image_skia, + reinterpret_cast(data.c_str()), + data.size(), width, height, scale_factor); skia_rep_added = true; } } @@ -459,8 +447,7 @@ void NativeImage::AddRepresentation(const mate::Dictionary& options) { } #if !defined(OS_MACOSX) -void NativeImage::SetTemplateImage(bool setAsTemplate) { -} +void NativeImage::SetTemplateImage(bool setAsTemplate) {} bool NativeImage::IsTemplateImage() { return false; @@ -473,22 +460,24 @@ mate::Handle NativeImage::CreateEmpty(v8::Isolate* isolate) { } // static -mate::Handle NativeImage::Create( - v8::Isolate* isolate, const gfx::Image& image) { +mate::Handle NativeImage::Create(v8::Isolate* isolate, + const gfx::Image& image) { return mate::CreateHandle(isolate, new NativeImage(isolate, image)); } // static -mate::Handle NativeImage::CreateFromPNG( - v8::Isolate* isolate, const char* buffer, size_t length) { +mate::Handle NativeImage::CreateFromPNG(v8::Isolate* isolate, + const char* buffer, + size_t length) { gfx::Image image = gfx::Image::CreateFrom1xPNGBytes( reinterpret_cast(buffer), length); return Create(isolate, image); } // static -mate::Handle NativeImage::CreateFromJPEG( - v8::Isolate* isolate, const char* buffer, size_t length) { +mate::Handle NativeImage::CreateFromJPEG(v8::Isolate* isolate, + const char* buffer, + size_t length) { gfx::Image image = gfx::ImageFrom1xJPEGEncodedData( reinterpret_cast(buffer), length); return Create(isolate, image); @@ -496,12 +485,12 @@ mate::Handle NativeImage::CreateFromJPEG( // static mate::Handle NativeImage::CreateFromPath( - v8::Isolate* isolate, const base::FilePath& path) { + v8::Isolate* isolate, + const base::FilePath& path) { base::FilePath image_path = NormalizePath(path); #if defined(OS_WIN) if (image_path.MatchesExtension(FILE_PATH_LITERAL(".ico"))) { - return mate::CreateHandle(isolate, - new NativeImage(isolate, image_path)); + return mate::CreateHandle(isolate, new NativeImage(isolate, image_path)); } #endif gfx::ImageSkia image_skia; @@ -517,7 +506,8 @@ mate::Handle NativeImage::CreateFromPath( // static mate::Handle NativeImage::CreateFromBuffer( - mate::Arguments* args, v8::Local buffer) { + mate::Arguments* args, + v8::Local buffer) { int width = 0; int height = 0; double scale_factor = 1.; @@ -535,16 +525,13 @@ mate::Handle NativeImage::CreateFromBuffer( gfx::ImageSkia image_skia; AddImageSkiaRep(&image_skia, reinterpret_cast(node::Buffer::Data(buffer)), - node::Buffer::Length(buffer), - width, - height, - scale_factor); + node::Buffer::Length(buffer), width, height, scale_factor); return Create(args->isolate(), gfx::Image(image_skia)); } // static -mate::Handle NativeImage::CreateFromDataURL( - v8::Isolate* isolate, const GURL& url) { +mate::Handle NativeImage::CreateFromDataURL(v8::Isolate* isolate, + const GURL& url) { std::string mime_type, charset, data; if (net::DataURL::Parse(url, &mime_type, &charset, &data)) { if (mime_type == "image/png") @@ -558,14 +545,15 @@ mate::Handle NativeImage::CreateFromDataURL( #if !defined(OS_MACOSX) mate::Handle NativeImage::CreateFromNamedImage( - mate::Arguments* args, const std::string& name) { + mate::Arguments* args, + const std::string& name) { return CreateEmpty(args->isolate()); } #endif // static -void NativeImage::BuildPrototype( - v8::Isolate* isolate, v8::Local prototype) { +void NativeImage::BuildPrototype(v8::Isolate* isolate, + v8::Local prototype) { prototype->SetClassName(mate::StringToV8(isolate, "NativeImage")); mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) .SetMethod("toPNG", &NativeImage::ToPNG) @@ -597,7 +585,8 @@ v8::Local Converter>::ToV8( } bool Converter>::FromV8( - v8::Isolate* isolate, v8::Local val, + v8::Isolate* isolate, + v8::Local val, mate::Handle* out) { // Try converting from file path. base::FilePath path; @@ -607,8 +596,8 @@ bool Converter>::FromV8( return !(*out)->image().IsEmpty(); } - WrappableBase* wrapper = static_cast(internal::FromV8Impl( - isolate, val)); + WrappableBase* wrapper = + static_cast(internal::FromV8Impl(isolate, val)); if (!wrapper) return false; @@ -620,8 +609,10 @@ bool Converter>::FromV8( namespace { -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { mate::Dictionary dict(context->GetIsolate(), exports); dict.SetMethod("createEmpty", &atom::api::NativeImage::CreateEmpty); dict.SetMethod("createFromPath", &atom::api::NativeImage::CreateFromPath); diff --git a/atom/common/api/atom_api_native_image.h b/atom/common/api/atom_api_native_image.h index 8bdca3a1a7b..f945e3d4df3 100644 --- a/atom/common/api/atom_api_native_image.h +++ b/atom/common/api/atom_api_native_image.h @@ -41,20 +41,24 @@ namespace api { class NativeImage : public mate::Wrappable { public: static mate::Handle CreateEmpty(v8::Isolate* isolate); - static mate::Handle Create( - v8::Isolate* isolate, const gfx::Image& image); - static mate::Handle CreateFromPNG( - v8::Isolate* isolate, const char* buffer, size_t length); - static mate::Handle CreateFromJPEG( - v8::Isolate* isolate, const char* buffer, size_t length); - static mate::Handle CreateFromPath( - v8::Isolate* isolate, const base::FilePath& path); + static mate::Handle Create(v8::Isolate* isolate, + const gfx::Image& image); + static mate::Handle CreateFromPNG(v8::Isolate* isolate, + const char* buffer, + size_t length); + static mate::Handle CreateFromJPEG(v8::Isolate* isolate, + const char* buffer, + size_t length); + static mate::Handle CreateFromPath(v8::Isolate* isolate, + const base::FilePath& path); static mate::Handle CreateFromBuffer( - mate::Arguments* args, v8::Local buffer); - static mate::Handle CreateFromDataURL( - v8::Isolate* isolate, const GURL& url); + mate::Arguments* args, + v8::Local buffer); + static mate::Handle CreateFromDataURL(v8::Isolate* isolate, + const GURL& url); static mate::Handle CreateFromNamedImage( - mate::Arguments* args, const std::string& name); + mate::Arguments* args, + const std::string& name); static void BuildPrototype(v8::Isolate* isolate, v8::Local prototype); @@ -77,13 +81,11 @@ class NativeImage : public mate::Wrappable { v8::Local ToJPEG(v8::Isolate* isolate, int quality); v8::Local ToBitmap(mate::Arguments* args); v8::Local GetBitmap(mate::Arguments* args); - v8::Local GetNativeHandle( - v8::Isolate* isolate, - mate::Arguments* args); + v8::Local GetNativeHandle(v8::Isolate* isolate, + mate::Arguments* args); mate::Handle Resize(v8::Isolate* isolate, const base::DictionaryValue& options); - mate::Handle Crop(v8::Isolate* isolate, - const gfx::Rect& rect); + mate::Handle Crop(v8::Isolate* isolate, const gfx::Rect& rect); std::string ToDataURL(mate::Arguments* args); bool IsEmpty(); gfx::Size GetSize(); @@ -112,16 +114,16 @@ class NativeImage : public mate::Wrappable { namespace mate { // A custom converter that allows converting path to NativeImage. -template<> +template <> struct Converter> { static v8::Local ToV8( v8::Isolate* isolate, const mate::Handle& val); - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, mate::Handle* out); }; } // namespace mate - #endif // ATOM_COMMON_API_ATOM_API_NATIVE_IMAGE_H_ diff --git a/atom/common/api/atom_api_shell.cc b/atom/common/api/atom_api_shell.cc index 231d2ea9cbe..1323cd6402d 100644 --- a/atom/common/api/atom_api_shell.cc +++ b/atom/common/api/atom_api_shell.cc @@ -18,12 +18,13 @@ namespace mate { -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Handle val, + static bool FromV8(v8::Isolate* isolate, + v8::Handle val, base::win::ShortcutOperation* out) { std::string operation; - if (!ConvertFromV8(isolate, val, & operation)) + if (!ConvertFromV8(isolate, val, &operation)) return false; if (operation.empty() || operation == "create") *out = base::win::SHORTCUT_CREATE_ALWAYS; @@ -109,8 +110,8 @@ bool WriteShortcutLink(const base::FilePath& shortcut_path, properties.set_app_id(str); base::win::ScopedCOMInitializer com_initializer; - return base::win::CreateOrUpdateShortcutLink( - shortcut_path, properties, operation); + return base::win::CreateOrUpdateShortcutLink(shortcut_path, properties, + operation); } v8::Local ReadShortcutLink(mate::Arguments* args, @@ -135,8 +136,10 @@ v8::Local ReadShortcutLink(mate::Arguments* args, } #endif -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { mate::Dictionary dict(context->GetIsolate(), exports); dict.SetMethod("showItemInFolder", &platform_util::ShowItemInFolder); dict.SetMethod("openItem", &platform_util::OpenItem); diff --git a/atom/common/api/atom_api_v8_util.cc b/atom/common/api/atom_api_v8_util.cc index f7edfd28cb3..0770f061acf 100644 --- a/atom/common/api/atom_api_v8_util.cc +++ b/atom/common/api/atom_api_v8_util.cc @@ -30,7 +30,7 @@ struct hash> { namespace mate { -template +template struct Converter> { static bool FromV8(v8::Isolate* isolate, v8::Local val, @@ -96,15 +96,17 @@ void TakeHeapSnapshot(v8::Isolate* isolate) { void RequestGarbageCollectionForTesting(v8::Isolate* isolate) { isolate->RequestGarbageCollectionForTesting( - v8::Isolate::GarbageCollectionType::kFullGarbageCollection); + v8::Isolate::GarbageCollectionType::kFullGarbageCollection); } bool IsSameOrigin(const GURL& l, const GURL& r) { return url::Origin(l).IsSameOriginWith(url::Origin(r)); } -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { mate::Dictionary dict(context->GetIsolate(), exports); dict.SetMethod("getHiddenValue", &GetHiddenValue); dict.SetMethod("setHiddenValue", &SetHiddenValue); diff --git a/atom/common/api/atom_bindings.cc b/atom/common/api/atom_bindings.cc index bc8bc4675d0..ccd9ebd6780 100644 --- a/atom/common/api/atom_bindings.cc +++ b/atom/common/api/atom_bindings.cc @@ -22,7 +22,9 @@ namespace atom { namespace { // Dummy class type that used for crashing the program. -struct DummyClass { bool crash; }; +struct DummyClass { + bool crash; +}; // Called when there is a fatal error in V8, we just crash the process here so // we can get the stack trace. @@ -33,7 +35,6 @@ void FatalErrorCallback(const char* location, const char* message) { } // namespace - AtomBindings::AtomBindings(uv_loop_t* loop) { uv_async_init(loop, &call_next_tick_async_, OnCallNextTick); call_next_tick_async_.data = this; @@ -44,8 +45,7 @@ AtomBindings::~AtomBindings() { uv_close(reinterpret_cast(&call_next_tick_async_), nullptr); } -void AtomBindings::BindTo(v8::Isolate* isolate, - v8::Local process) { +void AtomBindings::BindTo(v8::Isolate* isolate, v8::Local process) { v8::V8::SetFatalErrorHandler(FatalErrorCallback); mate::Dictionary dict(isolate, process); @@ -54,14 +54,14 @@ void AtomBindings::BindTo(v8::Isolate* isolate, dict.SetMethod("log", &Log); dict.SetMethod("getProcessMemoryInfo", &GetProcessMemoryInfo); dict.SetMethod("getSystemMemoryInfo", &GetSystemMemoryInfo); - dict.SetMethod("getCPUUsage", - base::Bind(&AtomBindings::GetCPUUsage, base::Unretained(this))); + dict.SetMethod("getCPUUsage", base::Bind(&AtomBindings::GetCPUUsage, + base::Unretained(this))); dict.SetMethod("getIOCounters", &GetIOCounters); #if defined(OS_POSIX) dict.SetMethod("setFdLimit", &base::SetFdLimit); #endif - dict.SetMethod("activateUvLoop", - base::Bind(&AtomBindings::ActivateUVLoop, base::Unretained(this))); + dict.SetMethod("activateUvLoop", base::Bind(&AtomBindings::ActivateUVLoop, + base::Unretained(this))); #if defined(MAS_BUILD) dict.Set("mas", true); @@ -76,8 +76,8 @@ void AtomBindings::BindTo(v8::Isolate* isolate, } void AtomBindings::EnvironmentDestroyed(node::Environment* env) { - auto it = std::find(pending_next_ticks_.begin(), pending_next_ticks_.end(), - env); + auto it = + std::find(pending_next_ticks_.begin(), pending_next_ticks_.end(), env); if (it != pending_next_ticks_.end()) pending_next_ticks_.erase(it); } @@ -102,9 +102,7 @@ void AtomBindings::OnCallNextTick(uv_async_t* handle) { mate::Locker locker(env->isolate()); v8::Context::Scope context_scope(env->context()); node::InternalCallbackScope scope( - env, - v8::Local(), - {0, 0}, + env, v8::Local(), {0, 0}, node::InternalCallbackScope::kAllowEmptyResource); } @@ -149,7 +147,7 @@ v8::Local AtomBindings::GetProcessMemoryInfo(v8::Isolate* isolate) { // static v8::Local AtomBindings::GetSystemMemoryInfo(v8::Isolate* isolate, - mate::Arguments* args) { + mate::Arguments* args) { base::SystemMemoryInfoKB mem_info; if (!base::GetSystemMemoryInfo(&mem_info)) { args->ThrowError("Unable to retrieve system memory information"); diff --git a/atom/common/api/atom_bindings.h b/atom/common/api/atom_bindings.h index a37497ccc5b..d46d047de50 100644 --- a/atom/common/api/atom_bindings.h +++ b/atom/common/api/atom_bindings.h @@ -37,7 +37,7 @@ class AtomBindings { static void Hang(); static v8::Local GetProcessMemoryInfo(v8::Isolate* isolate); static v8::Local GetSystemMemoryInfo(v8::Isolate* isolate, - mate::Arguments* args); + mate::Arguments* args); v8::Local GetCPUUsage(v8::Isolate* isolate); static v8::Local GetIOCounters(v8::Isolate* isolate); diff --git a/atom/common/api/event_emitter_caller.cc b/atom/common/api/event_emitter_caller.cc index ff920c67973..a3b9187d68e 100644 --- a/atom/common/api/event_emitter_caller.cc +++ b/atom/common/api/event_emitter_caller.cc @@ -20,9 +20,8 @@ v8::Local CallMethodWithArgs(v8::Isolate* isolate, v8::MicrotasksScope::kRunMicrotasks); // Use node::MakeCallback to call the callback, and it will also run pending // tasks in Node.js. - v8::MaybeLocal ret = node::MakeCallback(isolate, obj, method, - args->size(), - &args->front(), {0, 0}); + v8::MaybeLocal ret = node::MakeCallback( + isolate, obj, method, args->size(), &args->front(), {0, 0}); // If the JS function throws an exception (doesn't return a value) the result // of MakeCallback will be empty and therefore ToLocal will be false, in this // case we need to return "false" as that indicates that the event emitter did diff --git a/atom/common/api/event_emitter_caller.h b/atom/common/api/event_emitter_caller.h index 64322e562ef..023fb0a1d72 100644 --- a/atom/common/api/event_emitter_caller.h +++ b/atom/common/api/event_emitter_caller.h @@ -44,7 +44,8 @@ v8::Local EmitEvent(v8::Isolate* isolate, const StringType& name, const Args&... args) { internal::ValueVector converted_args = { - StringToV8(isolate, name), ConvertToV8(isolate, args)..., + StringToV8(isolate, name), + ConvertToV8(isolate, args)..., }; return internal::CallMethodWithArgs(isolate, obj, "emit", &converted_args); } diff --git a/atom/common/api/locker.cc b/atom/common/api/locker.cc index fe0b23479a4..0ae695a1f05 100644 --- a/atom/common/api/locker.cc +++ b/atom/common/api/locker.cc @@ -11,7 +11,6 @@ Locker::Locker(v8::Isolate* isolate) { locker_.reset(new v8::Locker(isolate)); } -Locker::~Locker() { -} +Locker::~Locker() {} } // namespace mate diff --git a/atom/common/api/object_life_monitor.cc b/atom/common/api/object_life_monitor.cc index cc68130d34b..4f83a76cf68 100644 --- a/atom/common/api/object_life_monitor.cc +++ b/atom/common/api/object_life_monitor.cc @@ -12,8 +12,7 @@ namespace atom { ObjectLifeMonitor::ObjectLifeMonitor(v8::Isolate* isolate, v8::Local target) - : target_(isolate, target), - weak_ptr_factory_(this) { + : target_(isolate, target), weak_ptr_factory_(this) { target_.SetWeak(this, OnObjectGC, v8::WeakCallbackType::kParameter); } diff --git a/atom/common/api/remote_callback_freer.cc b/atom/common/api/remote_callback_freer.cc index c15d5389a2e..dc9a7cd2cec 100644 --- a/atom/common/api/remote_callback_freer.cc +++ b/atom/common/api/remote_callback_freer.cc @@ -26,11 +26,9 @@ RemoteCallbackFreer::RemoteCallbackFreer(v8::Isolate* isolate, content::WebContents* web_contents) : ObjectLifeMonitor(isolate, target), content::WebContentsObserver(web_contents), - object_id_(object_id) { -} + object_id_(object_id) {} -RemoteCallbackFreer::~RemoteCallbackFreer() { -} +RemoteCallbackFreer::~RemoteCallbackFreer() {} void RemoteCallbackFreer::RunDestructor() { base::string16 channel = diff --git a/atom/common/api/remote_object_freer.cc b/atom/common/api/remote_object_freer.cc index ef028441e3d..142e6cb8622 100644 --- a/atom/common/api/remote_object_freer.cc +++ b/atom/common/api/remote_object_freer.cc @@ -27,13 +27,15 @@ content::RenderFrame* GetCurrentRenderFrame() { } // namespace // static -void RemoteObjectFreer::BindTo( - v8::Isolate* isolate, v8::Local target, int object_id) { +void RemoteObjectFreer::BindTo(v8::Isolate* isolate, + v8::Local target, + int object_id) { new RemoteObjectFreer(isolate, target, object_id); } -RemoteObjectFreer::RemoteObjectFreer( - v8::Isolate* isolate, v8::Local target, int object_id) +RemoteObjectFreer::RemoteObjectFreer(v8::Isolate* isolate, + v8::Local target, + int object_id) : ObjectLifeMonitor(isolate, target), object_id_(object_id), routing_id_(MSG_ROUTING_NONE) { @@ -43,8 +45,7 @@ RemoteObjectFreer::RemoteObjectFreer( } } -RemoteObjectFreer::~RemoteObjectFreer() { -} +RemoteObjectFreer::~RemoteObjectFreer() {} void RemoteObjectFreer::RunDestructor() { content::RenderFrame* render_frame = diff --git a/atom/common/api/remote_object_freer.h b/atom/common/api/remote_object_freer.h index f99c09537a7..ece52122dba 100644 --- a/atom/common/api/remote_object_freer.h +++ b/atom/common/api/remote_object_freer.h @@ -11,12 +11,14 @@ namespace atom { class RemoteObjectFreer : public ObjectLifeMonitor { public: - static void BindTo( - v8::Isolate* isolate, v8::Local target, int object_id); + static void BindTo(v8::Isolate* isolate, + v8::Local target, + int object_id); protected: - RemoteObjectFreer( - v8::Isolate* isolate, v8::Local target, int object_id); + RemoteObjectFreer(v8::Isolate* isolate, + v8::Local target, + int object_id); ~RemoteObjectFreer() override; void RunDestructor() override; diff --git a/atom/common/asar/archive.cc b/atom/common/asar/archive.cc index 84f9cd8dd5b..4d5465b9c5f 100644 --- a/atom/common/asar/archive.cc +++ b/atom/common/asar/archive.cc @@ -121,8 +121,7 @@ Archive::Archive(const base::FilePath& path) base::ThreadRestrictions::ScopedAllowIO allow_io; file_.Initialize(path_, base::File::FLAG_OPEN | base::File::FLAG_READ); #if defined(OS_WIN) - fd_ = - _open_osfhandle(reinterpret_cast(file_.GetPlatformFile()), 0); + fd_ = _open_osfhandle(reinterpret_cast(file_.GetPlatformFile()), 0); #elif defined(OS_POSIX) fd_ = file_.GetPlatformFile(); #else @@ -145,8 +144,8 @@ Archive::~Archive() { bool Archive::Init() { if (!file_.IsValid()) { if (file_.error_details() != base::File::FILE_ERROR_NOT_FOUND) { - LOG(WARNING) << "Opening " << path_.value() - << ": " << base::File::ErrorToString(file_.error_details()); + LOG(WARNING) << "Opening " << path_.value() << ": " + << base::File::ErrorToString(file_.error_details()); } return false; } @@ -165,8 +164,8 @@ bool Archive::Init() { } uint32_t size; - if (!base::PickleIterator(base::Pickle(buf.data(), buf.size())).ReadUInt32( - &size)) { + if (!base::PickleIterator(base::Pickle(buf.data(), buf.size())) + .ReadUInt32(&size)) { LOG(ERROR) << "Failed to parse header size from " << path_.value(); return false; } @@ -182,8 +181,8 @@ bool Archive::Init() { } std::string header; - if (!base::PickleIterator(base::Pickle(buf.data(), buf.size())).ReadString( - &header)) { + if (!base::PickleIterator(base::Pickle(buf.data(), buf.size())) + .ReadString(&header)) { LOG(ERROR) << "Failed to parse header from " << path_.value(); return false; } diff --git a/atom/common/asar/archive.h b/atom/common/asar/archive.h index 4796d1014b7..a7b11c8702a 100644 --- a/atom/common/asar/archive.h +++ b/atom/common/asar/archive.h @@ -76,7 +76,8 @@ class Archive { // Cached external temporary files. std::unordered_map> external_files_; + std::unique_ptr> + external_files_; DISALLOW_COPY_AND_ASSIGN(Archive); }; diff --git a/atom/common/asar/asar_util.cc b/atom/common/asar/asar_util.cc index 0ffbfc6c365..b564a75dc72 100644 --- a/atom/common/asar/asar_util.cc +++ b/atom/common/asar/asar_util.cc @@ -92,8 +92,9 @@ bool ReadFileToString(const base::FilePath& path, std::string* contents) { return false; contents->resize(info.size); - return static_cast(info.size) == src.Read( - info.offset, const_cast(contents->data()), contents->size()); + return static_cast(info.size) == + src.Read(info.offset, const_cast(contents->data()), + contents->size()); } } // namespace asar diff --git a/atom/common/asar/scoped_temporary_file.cc b/atom/common/asar/scoped_temporary_file.cc index 8578d90d907..f96eabc7a60 100644 --- a/atom/common/asar/scoped_temporary_file.cc +++ b/atom/common/asar/scoped_temporary_file.cc @@ -11,8 +11,7 @@ namespace asar { -ScopedTemporaryFile::ScopedTemporaryFile() { -} +ScopedTemporaryFile::ScopedTemporaryFile() {} ScopedTemporaryFile::~ScopedTemporaryFile() { if (!path_.empty()) { @@ -51,7 +50,8 @@ bool ScopedTemporaryFile::Init(const base::FilePath::StringType& ext) { bool ScopedTemporaryFile::InitFromFile(base::File* src, const base::FilePath::StringType& ext, - uint64_t offset, uint64_t size) { + uint64_t offset, + uint64_t size) { if (!src->IsValid()) return false; @@ -68,7 +68,7 @@ bool ScopedTemporaryFile::InitFromFile(base::File* src, return false; return dest.WriteAtCurrentPos(buf.data(), buf.size()) == - static_cast(size); + static_cast(size); } } // namespace asar diff --git a/atom/common/asar/scoped_temporary_file.h b/atom/common/asar/scoped_temporary_file.h index 5931d9b87af..4a55958b808 100644 --- a/atom/common/asar/scoped_temporary_file.h +++ b/atom/common/asar/scoped_temporary_file.h @@ -28,7 +28,8 @@ class ScopedTemporaryFile { // Init an temporary file and fill it with content of |path|. bool InitFromFile(base::File* src, const base::FilePath::StringType& ext, - uint64_t offset, uint64_t size); + uint64_t offset, + uint64_t size); base::FilePath path() const { return path_; } diff --git a/atom/common/atom_version.h b/atom/common/atom_version.h index 45ebe50d288..c5c1bf95ad9 100644 --- a/atom/common/atom_version.h +++ b/atom/common/atom_version.h @@ -16,24 +16,16 @@ #endif #ifndef ATOM_PRE_RELEASE_VERSION - #define ATOM_VERSION_STRING ATOM_STRINGIFY(ATOM_MAJOR_VERSION) "." \ - ATOM_STRINGIFY(ATOM_MINOR_VERSION) "." \ - ATOM_STRINGIFY(ATOM_PATCH_VERSION) +#define ATOM_VERSION_STRING \ + ATOM_STRINGIFY(ATOM_MAJOR_VERSION) \ + "." ATOM_STRINGIFY(ATOM_MINOR_VERSION) "." ATOM_STRINGIFY(ATOM_PATCH_VERSION) #else - #define ATOM_VERSION_STRING ATOM_STRINGIFY(ATOM_MAJOR_VERSION) "." \ - ATOM_STRINGIFY(ATOM_MINOR_VERSION) "." \ - ATOM_STRINGIFY(ATOM_PATCH_VERSION) \ - ATOM_STRINGIFY(ATOM_PRE_RELEASE_VERSION) +#define ATOM_VERSION_STRING \ + ATOM_STRINGIFY(ATOM_MAJOR_VERSION) \ + "." ATOM_STRINGIFY(ATOM_MINOR_VERSION) "." ATOM_STRINGIFY( \ + ATOM_PATCH_VERSION) ATOM_STRINGIFY(ATOM_PRE_RELEASE_VERSION) #endif - #define ATOM_VERSION "v" ATOM_VERSION_STRING - -#define ATOM_VERSION_AT_LEAST(major, minor, patch) \ - (( (major) < ATOM_MAJOR_VERSION) \ - || ((major) == ATOM_MAJOR_VERSION && (minor) < ATOM_MINOR_VERSION) \ - || ((major) == ATOM_MAJOR_VERSION && (minor) == ATOM_MINOR_VERSION \ - && (patch) <= ATOM_PATCH_VERSION)) - #endif // ATOM_COMMON_ATOM_VERSION_H_ diff --git a/atom/common/color_util.cc b/atom/common/color_util.cc index 4df25d184e8..9e357c39d04 100644 --- a/atom/common/color_util.cc +++ b/atom/common/color_util.cc @@ -47,10 +47,8 @@ SkColor ParseHexColor(const std::string& color_string) { } std::string ToRGBHex(SkColor color) { - return base::StringPrintf("#%02X%02X%02X", - SkColorGetR(color), - SkColorGetG(color), - SkColorGetB(color)); + return base::StringPrintf("#%02X%02X%02X", SkColorGetR(color), + SkColorGetG(color), SkColorGetB(color)); } } // namespace atom diff --git a/atom/common/common_message_generator.cc b/atom/common/common_message_generator.cc index 6b14637cf3c..09f5bdcfb02 100644 --- a/atom/common/common_message_generator.cc +++ b/atom/common/common_message_generator.cc @@ -8,10 +8,14 @@ // Generate constructors. #include "ipc/struct_constructor_macros.h" + +// must go after struct_contructor_macros #include "atom/common/common_message_generator.h" // Generate destructors. #include "ipc/struct_destructor_macros.h" + +// must go after struct_destructor_macros #include "atom/common/common_message_generator.h" // Generate param traits write methods. @@ -30,4 +34,4 @@ namespace IPC { #include "ipc/param_traits_log_macros.h" namespace IPC { #include "atom/common/common_message_generator.h" -} // namespace IPC +} // namespace IPC \ No newline at end of file diff --git a/atom/common/common_message_generator.h b/atom/common/common_message_generator.h index fac3d548c09..1e40d41d98e 100644 --- a/atom/common/common_message_generator.h +++ b/atom/common/common_message_generator.h @@ -5,7 +5,7 @@ // Multiply-included file, no traditional include guard. #include "atom/common/api/api_messages.h" +#include "chrome/common/chrome_utility_printing_messages.h" #include "chrome/common/print_messages.h" #include "chrome/common/tts_messages.h" #include "chrome/common/widevine_cdm_messages.h" -#include "chrome/common/chrome_utility_printing_messages.h" diff --git a/atom/common/crash_reporter/crash_reporter.cc b/atom/common/crash_reporter/crash_reporter.cc index 97476623e88..4b116ac643f 100644 --- a/atom/common/crash_reporter/crash_reporter.cc +++ b/atom/common/crash_reporter/crash_reporter.cc @@ -21,8 +21,7 @@ CrashReporter::CrashReporter() { is_browser_ = cmd->GetSwitchValueASCII(switches::kProcessType).empty(); } -CrashReporter::~CrashReporter() { -} +CrashReporter::~CrashReporter() {} void CrashReporter::Start(const std::string& product_name, const std::string& company_name, @@ -45,8 +44,7 @@ void CrashReporter::SetUploadParameters(const StringMap& parameters) { SetUploadParameters(); } -void CrashReporter::SetUploadToServer(const bool upload_to_server) { -} +void CrashReporter::SetUploadToServer(const bool upload_to_server) {} bool CrashReporter::GetUploadToServer() { return true; @@ -66,10 +64,10 @@ CrashReporter::GetUploadedReports(const base::FilePath& crashes_dir) { std::vector report_item = base::SplitString( report, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); int report_time = 0; - if (report_item.size() >= 2 && base::StringToInt(report_item[0], - &report_time)) { - result.push_back(CrashReporter::UploadReportResult(report_time, - report_item[1])); + if (report_item.size() >= 2 && + base::StringToInt(report_item[0], &report_time)) { + result.push_back( + CrashReporter::UploadReportResult(report_time, report_item[1])); } } } @@ -82,18 +80,14 @@ void CrashReporter::InitBreakpad(const std::string& product_name, const std::string& submit_url, const base::FilePath& crashes_dir, bool auto_submit, - bool skip_system_crash_handler) { -} + bool skip_system_crash_handler) {} -void CrashReporter::SetUploadParameters() { -} +void CrashReporter::SetUploadParameters() {} void CrashReporter::AddExtraParameter(const std::string& key, - const std::string& value) { -} + const std::string& value) {} -void CrashReporter::RemoveExtraParameter(const std::string& key) { -} +void CrashReporter::RemoveExtraParameter(const std::string& key) {} std::map CrashReporter::GetParameters() const { return upload_parameters_; @@ -109,7 +103,8 @@ CrashReporter* CrashReporter::GetInstance() { void CrashReporter::StartInstance(const mate::Dictionary& options) { auto reporter = GetInstance(); - if (!reporter) return; + if (!reporter) + return; std::string product_name; options.Get("productName", &product_name); diff --git a/atom/common/crash_reporter/crash_reporter_linux.cc b/atom/common/crash_reporter/crash_reporter_linux.cc index 881780d8589..988f55e690c 100644 --- a/atom/common/crash_reporter/crash_reporter_linux.cc +++ b/atom/common/crash_reporter/crash_reporter_linux.cc @@ -38,9 +38,7 @@ static const off_t kMaxMinidumpFileSize = 1258291; } // namespace CrashReporterLinux::CrashReporterLinux() - : process_start_time_(0), - pid_(getpid()), - upload_to_server_(true) { + : process_start_time_(0), pid_(getpid()), upload_to_server_(true) { // Set the base process start time value. struct timeval tv; if (!gettimeofday(&tv, NULL)) { @@ -54,8 +52,7 @@ CrashReporterLinux::CrashReporterLinux() base::SetLinuxDistro(base::GetLinuxDistro()); } -CrashReporterLinux::~CrashReporterLinux() { -} +CrashReporterLinux::~CrashReporterLinux() {} void CrashReporterLinux::InitBreakpad(const std::string& product_name, const std::string& version, @@ -101,13 +98,10 @@ void CrashReporterLinux::EnableCrashDumping(const base::FilePath& crashes_dir) { MinidumpDescriptor minidump_descriptor(crashes_dir.value()); minidump_descriptor.set_size_limit(kMaxMinidumpFileSize); - breakpad_.reset(new ExceptionHandler( - minidump_descriptor, - NULL, - CrashDone, - this, - true, // Install handlers. - -1)); + breakpad_.reset(new ExceptionHandler(minidump_descriptor, NULL, CrashDone, + this, + true, // Install handlers. + -1)); } bool CrashReporterLinux::CrashDone(const MinidumpDescriptor& minidump, diff --git a/atom/common/crash_reporter/crash_reporter_linux.h b/atom/common/crash_reporter/crash_reporter_linux.h index 75a57ec1c17..764e18007d2 100644 --- a/atom/common/crash_reporter/crash_reporter_linux.h +++ b/atom/common/crash_reporter/crash_reporter_linux.h @@ -13,13 +13,14 @@ #include "base/compiler_specific.h" namespace base { -template struct DefaultSingletonTraits; +template +struct DefaultSingletonTraits; } namespace google_breakpad { class ExceptionHandler; class MinidumpDescriptor; -} +} // namespace google_breakpad namespace crash_reporter { diff --git a/atom/common/crash_reporter/crash_reporter_mac.h b/atom/common/crash_reporter/crash_reporter_mac.h index c1b2431af6f..bd7eda5d71e 100644 --- a/atom/common/crash_reporter/crash_reporter_mac.h +++ b/atom/common/crash_reporter/crash_reporter_mac.h @@ -16,7 +16,8 @@ #include "vendor/crashpad/client/simple_string_dictionary.h" namespace base { -template struct DefaultSingletonTraits; +template +struct DefaultSingletonTraits; } namespace crash_reporter { diff --git a/atom/common/crash_reporter/crash_reporter_win.cc b/atom/common/crash_reporter/crash_reporter_win.cc index 49f90b7e666..a5510f6430b 100644 --- a/atom/common/crash_reporter/crash_reporter_win.cc +++ b/atom/common/crash_reporter/crash_reporter_win.cc @@ -38,7 +38,7 @@ namespace { // Minidump with stacks, PEB, TEB, and unloaded module list. const MINIDUMP_TYPE kSmallDumpType = static_cast( MiniDumpWithProcessThreadData | // Get PEB and TEB. - MiniDumpWithUnloadedModules); // Get unloaded modules when available. + MiniDumpWithUnloadedModules); // Get unloaded modules when available. const wchar_t kWaitEventFormat[] = L"$1CrashServiceWaitEvent"; const wchar_t kPipeNameFormat[] = L"\\\\.\\pipe\\$1 Crash Service"; @@ -47,8 +47,8 @@ const wchar_t kPipeNameFormat[] = L"\\\\.\\pipe\\$1 Crash Service"; const int kNameMaxLength = 64; const int kValueMaxLength = 64; -typedef NTSTATUS (WINAPI* NtTerminateProcessPtr)(HANDLE ProcessHandle, - NTSTATUS ExitStatus); +typedef NTSTATUS(WINAPI* NtTerminateProcessPtr)(HANDLE ProcessHandle, + NTSTATUS ExitStatus); char* g_real_terminate_process_stub = NULL; void TerminateProcessWithoutDump() { @@ -71,11 +71,11 @@ int CrashForExceptionInNonABICompliantCodeRange( ULONG64 EstablisherFrame, PCONTEXT ContextRecord, PDISPATCHER_CONTEXT DispatcherContext) { - EXCEPTION_POINTERS info = { ExceptionRecord, ContextRecord }; + EXCEPTION_POINTERS info = {ExceptionRecord, ContextRecord}; if (!CrashReporter::GetInstance()) return EXCEPTION_CONTINUE_SEARCH; - return static_cast(CrashReporter::GetInstance())-> - CrashForException(&info); + return static_cast(CrashReporter::GetInstance()) + ->CrashForException(&info); } struct ExceptionHandlerRecord { @@ -138,12 +138,9 @@ void UnregisterNonABICompliantCodeRange(void* start) { } // namespace CrashReporterWin::CrashReporterWin() - : skip_system_crash_handler_(false), - code_range_registered_(false) { -} + : skip_system_crash_handler_(false), code_range_registered_(false) {} -CrashReporterWin::~CrashReporterWin() { -} +CrashReporterWin::~CrashReporterWin() {} void CrashReporterWin::InitBreakpad(const std::string& product_name, const std::string& version, @@ -172,12 +169,8 @@ void CrashReporterWin::InitBreakpad(const std::string& product_name, breakpad_.reset(); breakpad_.reset(new google_breakpad::ExceptionHandler( - crashes_dir.DirName().value(), - FilterCallback, - MinidumpCallback, - this, - google_breakpad::ExceptionHandler::HANDLER_ALL, - kSmallDumpType, + crashes_dir.DirName().value(), FilterCallback, MinidumpCallback, this, + google_breakpad::ExceptionHandler::HANDLER_ALL, kSmallDumpType, pipe_name.c_str(), GetCustomInfo(product_name, version, company_name, upload_to_server))); @@ -246,13 +239,13 @@ google_breakpad::CustomClientInfo* CrashReporterWin::GetCustomInfo( custom_info_entries_.clear(); custom_info_entries_.reserve(3 + upload_parameters_.size()); - custom_info_entries_.push_back(google_breakpad::CustomInfoEntry( - L"prod", L"Electron")); + custom_info_entries_.push_back( + google_breakpad::CustomInfoEntry(L"prod", L"Electron")); custom_info_entries_.push_back(google_breakpad::CustomInfoEntry( L"ver", base::UTF8ToWide(version).c_str())); if (!upload_to_server) { - custom_info_entries_.push_back(google_breakpad::CustomInfoEntry( - L"skip_upload", L"1")); + custom_info_entries_.push_back( + google_breakpad::CustomInfoEntry(L"skip_upload", L"1")); } for (StringMap::const_iterator iter = upload_parameters_.begin(); diff --git a/atom/common/crash_reporter/crash_reporter_win.h b/atom/common/crash_reporter/crash_reporter_win.h index 5070df20600..3b3af71d5cf 100644 --- a/atom/common/crash_reporter/crash_reporter_win.h +++ b/atom/common/crash_reporter/crash_reporter_win.h @@ -14,7 +14,8 @@ #include "vendor/breakpad/src/client/windows/handler/exception_handler.h" namespace base { -template struct DefaultSingletonTraits; +template +struct DefaultSingletonTraits; } namespace crash_reporter { diff --git a/atom/common/crash_reporter/linux/crash_dump_handler.cc b/atom/common/crash_reporter/linux/crash_dump_handler.cc index 56a5e094d44..93805280650 100644 --- a/atom/common/crash_reporter/linux/crash_dump_handler.cc +++ b/atom/common/crash_reporter/linux/crash_dump_handler.cc @@ -23,7 +23,11 @@ // where we either a) know the call cannot fail, or b) there is nothing we // can do when a call fails, we mark the return code as ignored. This avoids // spurious compiler warnings. -#define IGNORE_RET(x) do { if (x); } while (0) +#define IGNORE_RET(x) \ + do { \ + if (x) \ + ; \ + } while (0) namespace crash_reporter { @@ -68,7 +72,7 @@ void my_uint64tos(char* output, uint64_t i, unsigned i_len) { } // Converts a struct timeval to milliseconds. -uint64_t kernel_timeval_to_ms(struct kernel_timeval *tv) { +uint64_t kernel_timeval_to_ms(struct kernel_timeval* tv) { uint64_t ret = tv->tv_sec; // Avoid overflow by explicitly using a uint64_t. ret *= 1000; ret += tv->tv_usec / 1000; @@ -116,8 +120,7 @@ class MimeWriter { size_t msg_data_size); // Append key/value pair. - void AddPairString(const char* msg_type, - const char* msg_data) { + void AddPairString(const char* msg_type, const char* msg_data) { AddPairData(msg_type, my_strlen(msg_type), msg_data, my_strlen(msg_data)); } @@ -145,9 +148,7 @@ class MimeWriter { protected: void AddItem(const void* base, size_t size); // Minor performance trade-off for easier-to-maintain code. - void AddString(const char* str) { - AddItem(str, my_strlen(str)); - } + void AddString(const char* str) { AddItem(str, my_strlen(str)); } void AddItemWithoutTrailingSpaces(const void* base, size_t size); struct kernel_iovec iov_[kIovCapacity]; @@ -163,13 +164,9 @@ class MimeWriter { }; MimeWriter::MimeWriter(int fd, const char* const mime_boundary) - : iov_index_(0), - fd_(fd), - mime_boundary_(mime_boundary) { -} + : iov_index_(0), fd_(fd), mime_boundary_(mime_boundary) {} -MimeWriter::~MimeWriter() { -} +MimeWriter::~MimeWriter() {} void MimeWriter::AddBoundary() { AddString(mime_boundary_); @@ -234,7 +231,8 @@ void MimeWriter::AddPairDataInChunks(const char* msg_type, } } -void MimeWriter::AddFileContents(const char* filename_msg, uint8_t* file_data, +void MimeWriter::AddFileContents(const char* filename_msg, + uint8_t* file_data, size_t file_size) { AddString(g_form_data_msg); AddString(filename_msg); @@ -257,12 +255,15 @@ void MimeWriter::AddItem(const void* base, size_t size) { } void MimeWriter::AddItemWithoutTrailingSpaces(const void* base, size_t size) { - AddItem(base, LengthWithoutTrailingSpaces(static_cast(base), - size)); + AddItem(base, + LengthWithoutTrailingSpaces(static_cast(base), size)); } void LoadDataFromFD(google_breakpad::PageAllocator* allocator, - int fd, bool close_fd, uint8_t** file_data, size_t* size) { + int fd, + bool close_fd, + uint8_t** file_data, + size_t* size) { struct kernel_stat st; if (sys_fstat(fd, &st) != 0) { static const char msg[] = "Cannot upload crash dump: stat failed\n"; @@ -298,7 +299,9 @@ void LoadDataFromFD(google_breakpad::PageAllocator* allocator, void LoadDataFromFile(google_breakpad::PageAllocator* allocator, const char* filename, - int* fd, uint8_t** file_data, size_t* size) { + int* fd, + uint8_t** file_data, + size_t* size) { // WARNING: this code runs in a compromised context. It may not call into // libc nor allocate memory normally. *fd = sys_open(filename, O_RDONLY, 0); @@ -329,8 +332,8 @@ void ExecUploadProcessOrTerminate(const BreakpadInfo& info, // where the boundary has two fewer leading '-' chars static const char header_msg[] = "--header=Content-Type: multipart/form-data; boundary="; - char* const header = reinterpret_cast(allocator->Alloc( - sizeof(header_msg) - 1 + strlen(mime_boundary) - 2 + 1)); + char* const header = reinterpret_cast( + allocator->Alloc(sizeof(header_msg) - 1 + strlen(mime_boundary) - 2 + 1)); memcpy(header, header_msg, sizeof(header_msg) - 1); memcpy(header + sizeof(header_msg) - 1, mime_boundary + 2, strlen(mime_boundary) - 2); @@ -339,26 +342,23 @@ void ExecUploadProcessOrTerminate(const BreakpadInfo& info, // The --post-file argument to wget looks like: // --post-file=/tmp/... static const char post_file_msg[] = "--post-file="; - char* const post_file = reinterpret_cast(allocator->Alloc( - sizeof(post_file_msg) - 1 + strlen(dumpfile) + 1)); + char* const post_file = reinterpret_cast( + allocator->Alloc(sizeof(post_file_msg) - 1 + strlen(dumpfile) + 1)); memcpy(post_file, post_file_msg, sizeof(post_file_msg) - 1); memcpy(post_file + sizeof(post_file_msg) - 1, dumpfile, strlen(dumpfile)); static const char kWgetBinary[] = "/usr/bin/wget"; const char* args[] = { - kWgetBinary, - header, - post_file, - info.upload_url, - "--timeout=60", // Set a timeout so we don't hang forever. - "--tries=1", // Don't retry if the upload fails. - "--quiet", // Be silent. - "-O", // output reply to /dev/null. - "/dev/fd/3", - NULL, + kWgetBinary, header, post_file, info.upload_url, + "--timeout=60", // Set a timeout so we don't hang forever. + "--tries=1", // Don't retry if the upload fails. + "--quiet", // Be silent. + "-O", // output reply to /dev/null. + "/dev/fd/3", NULL, }; - static const char msg[] = "Cannot upload crash dump: cannot exec " - "/usr/bin/wget\n"; + static const char msg[] = + "Cannot upload crash dump: cannot exec " + "/usr/bin/wget\n"; execve(args[0], const_cast(args), environ); WriteLog(msg, sizeof(msg) - 1); sys__exit(1); @@ -368,7 +368,8 @@ void ExecUploadProcessOrTerminate(const BreakpadInfo& info, // ExecUploadProcessOrTerminate() to finish. Returns the number of bytes written // to |fd| and save the written contents to |buf|. // |buf| needs to be big enough to hold |bytes_to_read| + 1 characters. -size_t WaitForCrashReportUploadProcess(int fd, size_t bytes_to_read, +size_t WaitForCrashReportUploadProcess(int fd, + size_t bytes_to_read, char* buf) { size_t bytes_read = 0; @@ -400,7 +401,8 @@ size_t WaitForCrashReportUploadProcess(int fd, size_t bytes_to_read, } // |buf| should be |expected_len| + 1 characters in size and NULL terminated. -bool IsValidCrashReportId(const char* buf, size_t bytes_read, +bool IsValidCrashReportId(const char* buf, + size_t bytes_read, size_t expected_len) { if (bytes_read != expected_len) return false; @@ -412,7 +414,8 @@ bool IsValidCrashReportId(const char* buf, size_t bytes_read, } // |buf| should be |expected_len| + 1 characters in size and NULL terminated. -void HandleCrashReportId(const char* buf, size_t bytes_read, +void HandleCrashReportId(const char* buf, + size_t bytes_read, size_t expected_len) { if (!IsValidCrashReportId(buf, bytes_read, expected_len)) { static const char msg[] = "Failed to get crash dump id."; @@ -472,7 +475,8 @@ void HandleCrashDump(const BreakpadInfo& info) { // The FD is pointing to the end of the file. // Rewind, we'll read the data next. if (lseek(dumpfd, 0, SEEK_SET) == -1) { - static const char msg[] = "Cannot upload crash dump: failed to " + static const char msg[] = + "Cannot upload crash dump: failed to " "reposition minidump FD\n"; WriteLog(msg, sizeof(msg) - 1); IGNORE_RET(sys_close(dumpfd)); @@ -482,16 +486,17 @@ void HandleCrashDump(const BreakpadInfo& info) { } else { // Dump is provided with a path. keep_fd = false; - LoadDataFromFile( - &allocator, info.filename, &dumpfd, &dump_data, &dump_size); + LoadDataFromFile(&allocator, info.filename, &dumpfd, &dump_data, + &dump_size); } // We need to build a MIME block for uploading to the server. Since we are // going to fork and run wget, it needs to be written to a temp file. const int ufd = sys_open("/dev/urandom", O_RDONLY, 0); if (ufd < 0) { - static const char msg[] = "Cannot upload crash dump because /dev/urandom" - " is missing\n"; + static const char msg[] = + "Cannot upload crash dump because /dev/urandom" + " is missing\n"; WriteLog(msg, sizeof(msg) - 1); return; } @@ -504,7 +509,8 @@ void HandleCrashDump(const BreakpadInfo& info) { temp_file_fd = dumpfd; // Rewind the destination, we are going to overwrite it. if (lseek(dumpfd, 0, SEEK_SET) == -1) { - static const char msg[] = "Cannot upload crash dump: failed to " + static const char msg[] = + "Cannot upload crash dump: failed to " "reposition minidump FD (2)\n"; WriteLog(msg, sizeof(msg) - 1); IGNORE_RET(sys_close(dumpfd)); @@ -525,7 +531,8 @@ void HandleCrashDump(const BreakpadInfo& info) { } if (temp_file_fd < 0) { - static const char msg[] = "Failed to create temporary file in /tmp: " + static const char msg[] = + "Failed to create temporary file in /tmp: " "cannot upload crash dump\n"; WriteLog(msg, sizeof(msg) - 1); IGNORE_RET(sys_close(ufd)); @@ -598,8 +605,8 @@ void HandleCrashDump(const BreakpadInfo& info) { uint64_t pid_value_len = my_uint64_len(info.pid); my_uint64tos(pid_value_buf, info.pid, pid_value_len); static const char pid_key_name[] = "pid"; - writer.AddPairData(pid_key_name, sizeof(pid_key_name) - 1, - pid_value_buf, pid_value_len); + writer.AddPairData(pid_key_name, sizeof(pid_key_name) - 1, pid_value_buf, + pid_value_len); writer.AddBoundary(); } writer.Flush(); @@ -636,8 +643,8 @@ void HandleCrashDump(const BreakpadInfo& info) { const unsigned oom_size_len = my_uint64_len(info.oom_size); my_uint64tos(oom_size_str, info.oom_size, oom_size_len); static const char oom_size_msg[] = "oom-size"; - writer.AddPairData(oom_size_msg, sizeof(oom_size_msg) - 1, - oom_size_str, oom_size_len); + writer.AddPairData(oom_size_msg, sizeof(oom_size_msg) - 1, oom_size_str, + oom_size_len); writer.AddBoundary(); writer.Flush(); } @@ -732,7 +739,7 @@ void HandleCrashDump(const BreakpadInfo& info) { // Main browser process. if (child <= 0) return; - (void) HANDLE_EINTR(sys_waitpid(child, NULL, 0)); + (void)HANDLE_EINTR(sys_waitpid(child, NULL, 0)); } size_t WriteLog(const char* buf, size_t nbytes) { diff --git a/atom/common/crash_reporter/linux/crash_dump_handler.h b/atom/common/crash_reporter/linux/crash_dump_handler.h index f10c5212254..1978a70126f 100644 --- a/atom/common/crash_reporter/linux/crash_dump_handler.h +++ b/atom/common/crash_reporter/linux/crash_dump_handler.h @@ -21,15 +21,15 @@ typedef google_breakpad::NonAllocatingMap<256, 256, 64> CrashKeyStorage; // The minidump information can either be contained in a file descriptor (fd) or // in a file (whose path is in filename). struct BreakpadInfo { - int fd; // File descriptor to the Breakpad dump data. - const char* filename; // Path to the Breakpad dump data. - const char* distro; // Linux distro string. - unsigned distro_length; // Length of |distro|. - bool upload; // Whether to upload or save crash dump. - uint64_t process_start_time; // Uptime of the crashing process. - size_t oom_size; // Amount of memory requested if OOM. - uint64_t pid; // PID where applicable. - const char* upload_url; // URL to upload the minidump. + int fd; // File descriptor to the Breakpad dump data. + const char* filename; // Path to the Breakpad dump data. + const char* distro; // Linux distro string. + unsigned distro_length; // Length of |distro|. + bool upload; // Whether to upload or save crash dump. + uint64_t process_start_time; // Uptime of the crashing process. + size_t oom_size; // Amount of memory requested if OOM. + uint64_t pid; // PID where applicable. + const char* upload_url; // URL to upload the minidump. CrashKeyStorage* crash_keys; }; diff --git a/atom/common/crash_reporter/win/crash_service.cc b/atom/common/crash_reporter/win/crash_service.cc index a306a567a71..5e0d07e63c1 100644 --- a/atom/common/crash_reporter/win/crash_service.cc +++ b/atom/common/crash_reporter/win/crash_service.cc @@ -36,7 +36,8 @@ const wchar_t kCheckPointFile[] = L"crash_checkpoint.txt"; typedef std::map CrashMap; bool CustomInfoToMap(const google_breakpad::ClientInfo* client_info, - const std::wstring& reporter_tag, CrashMap* map) { + const std::wstring& reporter_tag, + CrashMap* map) { google_breakpad::CustomClientInfo info = client_info->GetCustomInfo(); for (uintptr_t i = 0; i < info.count; ++i) { @@ -56,8 +57,9 @@ bool WriteCustomInfoToFile(const std::wstring& dump_path, const CrashMap& map) { file_path.resize(last_dot); file_path += L".txt"; - std::wofstream file(file_path.c_str(), - std::ios_base::out | std::ios_base::app | std::ios::binary); + std::wofstream file(file_path.c_str(), std::ios_base::out | + std::ios_base::app | + std::ios::binary); if (!file.is_open()) return false; @@ -81,8 +83,9 @@ bool WriteReportIDToFile(const std::wstring& dump_path, file_path.resize(last_slash); file_path += L"\\uploads.log"; - std::wofstream file(file_path.c_str(), - std::ios_base::out | std::ios_base::app | std::ios::binary); + std::wofstream file(file_path.c_str(), std::ios_base::out | + std::ios_base::app | + std::ios::binary); if (!file.is_open()) return false; @@ -98,8 +101,10 @@ bool WriteReportIDToFile(const std::wstring& dump_path, // The window procedure task is to handle when a) the user logs off. // b) the system shuts down or c) when the user closes the window. -LRESULT __stdcall CrashSvcWndProc(HWND hwnd, UINT message, - WPARAM wparam, LPARAM lparam) { +LRESULT __stdcall CrashSvcWndProc(HWND hwnd, + UINT message, + WPARAM wparam, + LPARAM lparam) { switch (message) { case WM_CLOSE: case WM_ENDSESSION: @@ -118,8 +123,8 @@ HWND g_top_window = NULL; bool CreateTopWindow(HINSTANCE instance, const base::string16& application_name, bool visible) { - base::string16 class_name = base::ReplaceStringPlaceholders( - kClassNameFormat, application_name, NULL); + base::string16 class_name = + base::ReplaceStringPlaceholders(kClassNameFormat, application_name, NULL); WNDCLASSEXW wcx = {0}; wcx.cbSize = sizeof(wcx); @@ -133,8 +138,8 @@ bool CreateTopWindow(HINSTANCE instance, // The window size is zero but being a popup window still shows in the // task bar and can be closed using the system menu or using task manager. HWND window = CreateWindowExW(0, wcx.lpszClassName, L"crash service", style, - CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, - NULL, NULL, instance, NULL); + CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL, + instance, NULL); if (!window) return false; @@ -148,15 +153,10 @@ bool CreateTopWindow(HINSTANCE instance, // finishes. class ProcessingLock { public: - ProcessingLock() { - ::InterlockedIncrement(&op_count_); - } - ~ProcessingLock() { - ::InterlockedDecrement(&op_count_); - } - static bool IsWorking() { - return (op_count_ != 0); - } + ProcessingLock() { ::InterlockedIncrement(&op_count_); } + ~ProcessingLock() { ::InterlockedDecrement(&op_count_); } + static bool IsWorking() { return (op_count_ != 0); } + private: static volatile LONG op_count_; }; @@ -171,21 +171,22 @@ struct DumpJobInfo { CrashMap map; std::wstring dump_path; - DumpJobInfo(DWORD process_id, CrashService* service, - const CrashMap& crash_map, const std::wstring& path) - : pid(process_id), self(service), map(crash_map), dump_path(path) { - } + DumpJobInfo(DWORD process_id, + CrashService* service, + const CrashMap& crash_map, + const std::wstring& path) + : pid(process_id), self(service), map(crash_map), dump_path(path) {} }; } // namespace // Command line switches: -const char CrashService::kMaxReports[] = "max-reports"; -const char CrashService::kNoWindow[] = "no-window"; -const char CrashService::kReporterTag[] = "reporter"; -const char CrashService::kDumpsDir[] = "dumps-dir"; -const char CrashService::kPipeName[] = "pipe-name"; -const char CrashService::kReporterURL[] = "reporter-url"; +const char CrashService::kMaxReports[] = "max-reports"; +const char CrashService::kNoWindow[] = "no-window"; +const char CrashService::kReporterTag[] = "reporter"; +const char CrashService::kDumpsDir[] = "dumps-dir"; +const char CrashService::kPipeName[] = "pipe-name"; +const char CrashService::kReporterURL[] = "reporter-url"; CrashService::CrashService() : sender_(NULL), @@ -193,8 +194,7 @@ CrashService::CrashService() requests_handled_(0), requests_sent_(0), clients_connected_(0), - clients_terminated_(0) { -} + clients_terminated_(0) {} CrashService::~CrashService() { base::AutoLock lock(sending_); @@ -205,8 +205,8 @@ CrashService::~CrashService() { bool CrashService::Initialize(const base::string16& application_name, const base::FilePath& operating_dir, const base::FilePath& dumps_path) { - using google_breakpad::CrashReportSender; using google_breakpad::CrashGenerationServer; + using google_breakpad::CrashReportSender; std::wstring pipe_name = kTestPipeName; int max_reports = -1; @@ -249,12 +249,10 @@ bool CrashService::Initialize(const base::string16& application_name, security_attributes.bInheritHandle = FALSE; // Create the OOP crash generator object. - dumper_ = new CrashGenerationServer(pipe_name, &security_attributes, - &CrashService::OnClientConnected, this, - &CrashService::OnClientDumpRequest, this, - &CrashService::OnClientExited, this, - NULL, NULL, - true, &dumps_path_to_use.value()); + dumper_ = new CrashGenerationServer( + pipe_name, &security_attributes, &CrashService::OnClientConnected, this, + &CrashService::OnClientDumpRequest, this, &CrashService::OnClientExited, + this, NULL, NULL, true, &dumps_path_to_use.value()); if (!dumper_) { LOG(ERROR) << "could not create dumper"; @@ -263,8 +261,7 @@ bool CrashService::Initialize(const base::string16& application_name, return false; } - if (!CreateTopWindow(::GetModuleHandleW(NULL), - application_name, + if (!CreateTopWindow(::GetModuleHandleW(NULL), application_name, !cmd_line.HasSwitch(kNoWindow))) { LOG(ERROR) << "could not create window"; if (security_attributes.lpSecurityDescriptor) @@ -281,13 +278,13 @@ bool CrashService::Initialize(const base::string16& application_name, reporter_url_ = cmd_line.GetSwitchValueNative(kReporterURL); // Log basic information. - VLOG(1) << "pipe name is " << pipe_name - << "\ndumps at " << dumps_path_to_use.value(); + VLOG(1) << "pipe name is " << pipe_name << "\ndumps at " + << dumps_path_to_use.value(); if (sender_) { - VLOG(1) << "checkpoint is " << checkpoint_path.value() - << "\nserver is " << reporter_url_ - << "\nmaximum " << sender_->max_reports_per_day() << " reports/day" + VLOG(1) << "checkpoint is " << checkpoint_path.value() << "\nserver is " + << reporter_url_ << "\nmaximum " << sender_->max_reports_per_day() + << " reports/day" << "\nreporter is " << reporter_tag_; } // Start servicing clients. @@ -303,15 +300,16 @@ bool CrashService::Initialize(const base::string16& application_name, // Create or open an event to signal the browser process that the crash // service is initialized. - base::string16 wait_name = base::ReplaceStringPlaceholders( - kWaitEventFormat, application_name, NULL); + base::string16 wait_name = + base::ReplaceStringPlaceholders(kWaitEventFormat, application_name, NULL); HANDLE wait_event = ::CreateEventW(NULL, TRUE, TRUE, wait_name.c_str()); ::SetEvent(wait_event); return true; } -void CrashService::OnClientConnected(void* context, +void CrashService::OnClientConnected( + void* context, const google_breakpad::ClientInfo* client_info) { ProcessingLock lock; VLOG(1) << "client start. pid = " << client_info->pid(); @@ -319,7 +317,8 @@ void CrashService::OnClientConnected(void* context, ::InterlockedIncrement(&self->clients_connected_); } -void CrashService::OnClientExited(void* context, +void CrashService::OnClientExited( + void* context, const google_breakpad::ClientInfo* client_info) { ProcessingLock processing_lock; VLOG(1) << "client end. pid = " << client_info->pid(); @@ -349,7 +348,8 @@ void CrashService::OnClientExited(void* context, } } -void CrashService::OnClientDumpRequest(void* context, +void CrashService::OnClientDumpRequest( + void* context, const google_breakpad::ClientInfo* client_info, const std::wstring* file_path) { ProcessingLock lock; @@ -378,8 +378,8 @@ void CrashService::OnClientDumpRequest(void* context, if (it != map.end()) { base::FilePath alternate_dump_location = base::FilePath(it->second); base::CreateDirectoryW(alternate_dump_location); - alternate_dump_location = alternate_dump_location.Append( - dump_location.BaseName()); + alternate_dump_location = + alternate_dump_location.Append(dump_location.BaseName()); base::Move(dump_location, alternate_dump_location); dump_location = alternate_dump_location; } @@ -396,10 +396,10 @@ void CrashService::OnClientDumpRequest(void* context, // Send the crash dump using a worker thread. This operation has retry // logic in case there is no internet connection at the time. - DumpJobInfo* dump_job = new DumpJobInfo(pid, self, map, - dump_location.value()); - if (!::QueueUserWorkItem(&CrashService::AsyncSendDump, - dump_job, WT_EXECUTELONGFUNCTION)) { + DumpJobInfo* dump_job = + new DumpJobInfo(pid, self, map, dump_location.value()); + if (!::QueueUserWorkItem(&CrashService::AsyncSendDump, dump_job, + WT_EXECUTELONGFUNCTION)) { LOG(ERROR) << "could not queue job"; } } @@ -414,16 +414,11 @@ DWORD CrashService::AsyncSendDump(void* context) { std::wstring report_id = L""; - const DWORD kOneMinute = 60*1000; - const DWORD kOneHour = 60*kOneMinute; + const DWORD kOneMinute = 60 * 1000; + const DWORD kOneHour = 60 * kOneMinute; - const DWORD kSleepSchedule[] = { - 24*kOneHour, - 8*kOneHour, - 4*kOneHour, - kOneHour, - 15*kOneMinute, - 0}; + const DWORD kSleepSchedule[] = {24 * kOneHour, 8 * kOneHour, 4 * kOneHour, + kOneHour, 15 * kOneMinute, 0}; int retry_round = arraysize(kSleepSchedule) - 1; @@ -436,11 +431,9 @@ DWORD CrashService::AsyncSendDump(void* context) { VLOG(1) << "trying to send report for pid = " << info->pid; std::map file_map; file_map[L"upload_file_minidump"] = info->dump_path; - google_breakpad::ReportResult send_result - = info->self->sender_->SendCrashReport(info->self->reporter_url_, - info->map, - file_map, - &report_id); + google_breakpad::ReportResult send_result = + info->self->sender_->SendCrashReport(info->self->reporter_url_, + info->map, file_map, &report_id); switch (send_result) { case google_breakpad::RESULT_FAILED: report_id = L""; @@ -507,9 +500,8 @@ PSECURITY_DESCRIPTOR CrashService::GetSecurityDescriptorForLowIntegrity() { BOOL sacl_present = FALSE; BOOL sacl_defaulted = FALSE; - if (::ConvertStringSecurityDescriptorToSecurityDescriptorW(sddl.c_str(), - SDDL_REVISION, - &sec_desc, NULL)) { + if (::ConvertStringSecurityDescriptorToSecurityDescriptorW( + sddl.c_str(), SDDL_REVISION, &sec_desc, NULL)) { if (::GetSecurityDescriptorSacl(sec_desc, &sacl_present, &sacl, &sacl_defaulted)) { return sec_desc; diff --git a/atom/common/crash_reporter/win/crash_service.h b/atom/common/crash_reporter/win/crash_service.h index 634478ef64f..160a0c4ce5f 100644 --- a/atom/common/crash_reporter/win/crash_service.h +++ b/atom/common/crash_reporter/win/crash_service.h @@ -17,7 +17,7 @@ class CrashReportSender; class CrashGenerationServer; class ClientInfo; -} +} // namespace google_breakpad namespace breakpad { @@ -70,17 +70,11 @@ class CrashService { static const char kReporterURL[]; // Returns number of crash dumps handled. - int requests_handled() const { - return requests_handled_; - } + int requests_handled() const { return requests_handled_; } // Returns number of crash clients registered. - int clients_connected() const { - return clients_connected_; - } + int clients_connected() const { return clients_connected_; } // Returns number of crash clients terminated. - int clients_terminated() const { - return clients_terminated_; - } + int clients_terminated() const { return clients_terminated_; } // Starts the processing loop. This function does not return unless the // user is logging off or the user closes the crash service window. The diff --git a/atom/common/crash_reporter/win/crash_service_main.cc b/atom/common/crash_reporter/win/crash_service_main.cc index abeb2c1060e..c25ee858de0 100644 --- a/atom/common/crash_reporter/win/crash_service_main.cc +++ b/atom/common/crash_reporter/win/crash_service_main.cc @@ -21,8 +21,11 @@ const char kCrashesDirectory[] = "crashes-directory"; const wchar_t kPipeNameFormat[] = L"\\\\.\\pipe\\$1 Crash Service"; const wchar_t kStandardLogFile[] = L"operation_log.txt"; -void InvalidParameterHandler(const wchar_t*, const wchar_t*, const wchar_t*, - unsigned int, uintptr_t) { +void InvalidParameterHandler(const wchar_t*, + const wchar_t*, + const wchar_t*, + unsigned int, + uintptr_t) { // noop. } @@ -51,8 +54,8 @@ int Main(const wchar_t* cmd) { << kApplicationName; return 1; } - std::wstring application_name = cmd_line.GetSwitchValueNative( - kApplicationName); + std::wstring application_name = + cmd_line.GetSwitchValueNative(kApplicationName); if (!cmd_line.HasSwitch(kCrashesDirectory)) { LOG(ERROR) << "Crashes directory path must be specified with --" @@ -78,17 +81,15 @@ int Main(const wchar_t* cmd) { VLOG(1) << "Session start. cmdline is [" << cmd << "]"; // Setting the crash reporter. - base::string16 pipe_name = base::ReplaceStringPlaceholders(kPipeNameFormat, - application_name, - NULL); + base::string16 pipe_name = + base::ReplaceStringPlaceholders(kPipeNameFormat, application_name, NULL); cmd_line.AppendSwitch("no-window"); cmd_line.AppendSwitchASCII("max-reports", "128"); cmd_line.AppendSwitchASCII("reporter", ATOM_PROJECT_NAME "-crash-service"); cmd_line.AppendSwitchNative("pipe-name", pipe_name); breakpad::CrashService crash_service; - if (!crash_service.Initialize(application_name, operating_dir, - operating_dir)) + if (!crash_service.Initialize(application_name, operating_dir, operating_dir)) return 2; VLOG(1) << "Ready to process crash requests"; diff --git a/atom/common/draggable_region.cc b/atom/common/draggable_region.cc index f57719448a0..a571b2edf2b 100644 --- a/atom/common/draggable_region.cc +++ b/atom/common/draggable_region.cc @@ -6,8 +6,6 @@ namespace atom { -DraggableRegion::DraggableRegion() - : draggable(false) { -} +DraggableRegion::DraggableRegion() : draggable(false) {} } // namespace atom diff --git a/atom/common/google_api_key.h b/atom/common/google_api_key.h index e7a3209906d..d27934595ea 100644 --- a/atom/common/google_api_key.h +++ b/atom/common/google_api_key.h @@ -7,7 +7,7 @@ #ifndef GOOGLEAPIS_ENDPOINT #define GOOGLEAPIS_ENDPOINT \ - "https://www.googleapis.com/geolocation/v1/geolocate?key=" + "https://www.googleapis.com/geolocation/v1/geolocate?key=" #endif #ifndef GOOGLEAPIS_API_KEY diff --git a/atom/common/key_weak_map.h b/atom/common/key_weak_map.h index 8e879d656e8..9588519335a 100644 --- a/atom/common/key_weak_map.h +++ b/atom/common/key_weak_map.h @@ -15,7 +15,7 @@ namespace atom { // Like ES6's WeakMap, but the key is Integer and the value is Weak Pointer. -template +template class KeyWeakMap { public: // Records the key and self, used by SetWeak. @@ -48,9 +48,7 @@ class KeyWeakMap { } // Whethere there is an object with |key| in this WeakMap. - bool Has(const K& key) const { - return map_.find(key) != map_.end(); - } + bool Has(const K& key) const { return map_.find(key) != map_.end(); } // Returns all objects. std::vector> Values(v8::Isolate* isolate) const { @@ -79,8 +77,7 @@ class KeyWeakMap { } // Map of stored objects. - std::unordered_map< - K, std::pair>> map_; + std::unordered_map>> map_; DISALLOW_COPY_AND_ASSIGN(KeyWeakMap); }; diff --git a/atom/common/keyboard_util.cc b/atom/common/keyboard_util.cc index 7fee47675db..b8caa1f1b00 100644 --- a/atom/common/keyboard_util.cc +++ b/atom/common/keyboard_util.cc @@ -20,64 +20,160 @@ ui::KeyboardCode KeyboardCodeFromCharCode(base::char16 c, bool* shifted) { c = base::ToLowerASCII(c); *shifted = false; switch (c) { - case 0x08: return ui::VKEY_BACK; - case 0x7F: return ui::VKEY_DELETE; - case 0x09: return ui::VKEY_TAB; - case 0x0D: return ui::VKEY_RETURN; - case 0x1B: return ui::VKEY_ESCAPE; - case ' ': return ui::VKEY_SPACE; + case 0x08: + return ui::VKEY_BACK; + case 0x7F: + return ui::VKEY_DELETE; + case 0x09: + return ui::VKEY_TAB; + case 0x0D: + return ui::VKEY_RETURN; + case 0x1B: + return ui::VKEY_ESCAPE; + case ' ': + return ui::VKEY_SPACE; - case 'a': return ui::VKEY_A; - case 'b': return ui::VKEY_B; - case 'c': return ui::VKEY_C; - case 'd': return ui::VKEY_D; - case 'e': return ui::VKEY_E; - case 'f': return ui::VKEY_F; - case 'g': return ui::VKEY_G; - case 'h': return ui::VKEY_H; - case 'i': return ui::VKEY_I; - case 'j': return ui::VKEY_J; - case 'k': return ui::VKEY_K; - case 'l': return ui::VKEY_L; - case 'm': return ui::VKEY_M; - case 'n': return ui::VKEY_N; - case 'o': return ui::VKEY_O; - case 'p': return ui::VKEY_P; - case 'q': return ui::VKEY_Q; - case 'r': return ui::VKEY_R; - case 's': return ui::VKEY_S; - case 't': return ui::VKEY_T; - case 'u': return ui::VKEY_U; - case 'v': return ui::VKEY_V; - case 'w': return ui::VKEY_W; - case 'x': return ui::VKEY_X; - case 'y': return ui::VKEY_Y; - case 'z': return ui::VKEY_Z; + case 'a': + return ui::VKEY_A; + case 'b': + return ui::VKEY_B; + case 'c': + return ui::VKEY_C; + case 'd': + return ui::VKEY_D; + case 'e': + return ui::VKEY_E; + case 'f': + return ui::VKEY_F; + case 'g': + return ui::VKEY_G; + case 'h': + return ui::VKEY_H; + case 'i': + return ui::VKEY_I; + case 'j': + return ui::VKEY_J; + case 'k': + return ui::VKEY_K; + case 'l': + return ui::VKEY_L; + case 'm': + return ui::VKEY_M; + case 'n': + return ui::VKEY_N; + case 'o': + return ui::VKEY_O; + case 'p': + return ui::VKEY_P; + case 'q': + return ui::VKEY_Q; + case 'r': + return ui::VKEY_R; + case 's': + return ui::VKEY_S; + case 't': + return ui::VKEY_T; + case 'u': + return ui::VKEY_U; + case 'v': + return ui::VKEY_V; + case 'w': + return ui::VKEY_W; + case 'x': + return ui::VKEY_X; + case 'y': + return ui::VKEY_Y; + case 'z': + return ui::VKEY_Z; - case ')': *shifted = true; case '0': return ui::VKEY_0; - case '!': *shifted = true; case '1': return ui::VKEY_1; - case '@': *shifted = true; case '2': return ui::VKEY_2; - case '#': *shifted = true; case '3': return ui::VKEY_3; - case '$': *shifted = true; case '4': return ui::VKEY_4; - case '%': *shifted = true; case '5': return ui::VKEY_5; - case '^': *shifted = true; case '6': return ui::VKEY_6; - case '&': *shifted = true; case '7': return ui::VKEY_7; - case '*': *shifted = true; case '8': return ui::VKEY_8; - case '(': *shifted = true; case '9': return ui::VKEY_9; + case ')': + *shifted = true; + case '0': + return ui::VKEY_0; + case '!': + *shifted = true; + case '1': + return ui::VKEY_1; + case '@': + *shifted = true; + case '2': + return ui::VKEY_2; + case '#': + *shifted = true; + case '3': + return ui::VKEY_3; + case '$': + *shifted = true; + case '4': + return ui::VKEY_4; + case '%': + *shifted = true; + case '5': + return ui::VKEY_5; + case '^': + *shifted = true; + case '6': + return ui::VKEY_6; + case '&': + *shifted = true; + case '7': + return ui::VKEY_7; + case '*': + *shifted = true; + case '8': + return ui::VKEY_8; + case '(': + *shifted = true; + case '9': + return ui::VKEY_9; - case ':': *shifted = true; case ';': return ui::VKEY_OEM_1; - case '+': *shifted = true; case '=': return ui::VKEY_OEM_PLUS; - case '<': *shifted = true; case ',': return ui::VKEY_OEM_COMMA; - case '_': *shifted = true; case '-': return ui::VKEY_OEM_MINUS; - case '>': *shifted = true; case '.': return ui::VKEY_OEM_PERIOD; - case '?': *shifted = true; case '/': return ui::VKEY_OEM_2; - case '~': *shifted = true; case '`': return ui::VKEY_OEM_3; - case '{': *shifted = true; case '[': return ui::VKEY_OEM_4; - case '|': *shifted = true; case '\\': return ui::VKEY_OEM_5; - case '}': *shifted = true; case ']': return ui::VKEY_OEM_6; - case '"': *shifted = true; case '\'': return ui::VKEY_OEM_7; + case ':': + *shifted = true; + case ';': + return ui::VKEY_OEM_1; + case '+': + *shifted = true; + case '=': + return ui::VKEY_OEM_PLUS; + case '<': + *shifted = true; + case ',': + return ui::VKEY_OEM_COMMA; + case '_': + *shifted = true; + case '-': + return ui::VKEY_OEM_MINUS; + case '>': + *shifted = true; + case '.': + return ui::VKEY_OEM_PERIOD; + case '?': + *shifted = true; + case '/': + return ui::VKEY_OEM_2; + case '~': + *shifted = true; + case '`': + return ui::VKEY_OEM_3; + case '{': + *shifted = true; + case '[': + return ui::VKEY_OEM_4; + case '|': + *shifted = true; + case '\\': + return ui::VKEY_OEM_5; + case '}': + *shifted = true; + case ']': + return ui::VKEY_OEM_6; + case '"': + *shifted = true; + case '\'': + return ui::VKEY_OEM_7; - default: return ui::VKEY_UNKNOWN; + default: + return ui::VKEY_UNKNOWN; } } diff --git a/atom/common/linux/application_info.cc b/atom/common/linux/application_info.cc index 05bd7f6fc15..3354c73b8b6 100644 --- a/atom/common/linux/application_info.cc +++ b/atom/common/linux/application_info.cc @@ -19,7 +19,7 @@ namespace { GDesktopAppInfo* get_desktop_app_info() { - GDesktopAppInfo * ret = nullptr; + GDesktopAppInfo* ret = nullptr; std::string desktop_id; if (brightray::platform_util::GetDesktopName(&desktop_id)) diff --git a/atom/common/mouse_util.cc b/atom/common/mouse_util.cc index 7355a20c54b..d87be5b504e 100644 --- a/atom/common/mouse_util.cc +++ b/atom/common/mouse_util.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -#include #include "atom/common/mouse_util.h" +#include using Cursor = blink::WebCursorInfo::Type; @@ -11,51 +11,96 @@ namespace atom { std::string CursorTypeToString(const content::CursorInfo& info) { switch (info.type) { - case Cursor::kTypePointer: return "default"; - case Cursor::kTypeCross: return "crosshair"; - case Cursor::kTypeHand: return "pointer"; - case Cursor::kTypeIBeam: return "text"; - case Cursor::kTypeWait: return "wait"; - case Cursor::kTypeHelp: return "help"; - case Cursor::kTypeEastResize: return "e-resize"; - case Cursor::kTypeNorthResize: return "n-resize"; - case Cursor::kTypeNorthEastResize: return "ne-resize"; - case Cursor::kTypeNorthWestResize: return "nw-resize"; - case Cursor::kTypeSouthResize: return "s-resize"; - case Cursor::kTypeSouthEastResize: return "se-resize"; - case Cursor::kTypeSouthWestResize: return "sw-resize"; - case Cursor::kTypeWestResize: return "w-resize"; - case Cursor::kTypeNorthSouthResize: return "ns-resize"; - case Cursor::kTypeEastWestResize: return "ew-resize"; - case Cursor::kTypeNorthEastSouthWestResize: return "nesw-resize"; - case Cursor::kTypeNorthWestSouthEastResize: return "nwse-resize"; - case Cursor::kTypeColumnResize: return "col-resize"; - case Cursor::kTypeRowResize: return "row-resize"; - case Cursor::kTypeMiddlePanning: return "m-panning"; - case Cursor::kTypeEastPanning: return "e-panning"; - case Cursor::kTypeNorthPanning: return "n-panning"; - case Cursor::kTypeNorthEastPanning: return "ne-panning"; - case Cursor::kTypeNorthWestPanning: return "nw-panning"; - case Cursor::kTypeSouthPanning: return "s-panning"; - case Cursor::kTypeSouthEastPanning: return "se-panning"; - case Cursor::kTypeSouthWestPanning: return "sw-panning"; - case Cursor::kTypeWestPanning: return "w-panning"; - case Cursor::kTypeMove: return "move"; - case Cursor::kTypeVerticalText: return "vertical-text"; - case Cursor::kTypeCell: return "cell"; - case Cursor::kTypeContextMenu: return "context-menu"; - case Cursor::kTypeAlias: return "alias"; - case Cursor::kTypeProgress: return "progress"; - case Cursor::kTypeNoDrop: return "nodrop"; - case Cursor::kTypeCopy: return "copy"; - case Cursor::kTypeNone: return "none"; - case Cursor::kTypeNotAllowed: return "not-allowed"; - case Cursor::kTypeZoomIn: return "zoom-in"; - case Cursor::kTypeZoomOut: return "zoom-out"; - case Cursor::kTypeGrab: return "grab"; - case Cursor::kTypeGrabbing: return "grabbing"; - case Cursor::kTypeCustom: return "custom"; - default: return "default"; + case Cursor::kTypePointer: + return "default"; + case Cursor::kTypeCross: + return "crosshair"; + case Cursor::kTypeHand: + return "pointer"; + case Cursor::kTypeIBeam: + return "text"; + case Cursor::kTypeWait: + return "wait"; + case Cursor::kTypeHelp: + return "help"; + case Cursor::kTypeEastResize: + return "e-resize"; + case Cursor::kTypeNorthResize: + return "n-resize"; + case Cursor::kTypeNorthEastResize: + return "ne-resize"; + case Cursor::kTypeNorthWestResize: + return "nw-resize"; + case Cursor::kTypeSouthResize: + return "s-resize"; + case Cursor::kTypeSouthEastResize: + return "se-resize"; + case Cursor::kTypeSouthWestResize: + return "sw-resize"; + case Cursor::kTypeWestResize: + return "w-resize"; + case Cursor::kTypeNorthSouthResize: + return "ns-resize"; + case Cursor::kTypeEastWestResize: + return "ew-resize"; + case Cursor::kTypeNorthEastSouthWestResize: + return "nesw-resize"; + case Cursor::kTypeNorthWestSouthEastResize: + return "nwse-resize"; + case Cursor::kTypeColumnResize: + return "col-resize"; + case Cursor::kTypeRowResize: + return "row-resize"; + case Cursor::kTypeMiddlePanning: + return "m-panning"; + case Cursor::kTypeEastPanning: + return "e-panning"; + case Cursor::kTypeNorthPanning: + return "n-panning"; + case Cursor::kTypeNorthEastPanning: + return "ne-panning"; + case Cursor::kTypeNorthWestPanning: + return "nw-panning"; + case Cursor::kTypeSouthPanning: + return "s-panning"; + case Cursor::kTypeSouthEastPanning: + return "se-panning"; + case Cursor::kTypeSouthWestPanning: + return "sw-panning"; + case Cursor::kTypeWestPanning: + return "w-panning"; + case Cursor::kTypeMove: + return "move"; + case Cursor::kTypeVerticalText: + return "vertical-text"; + case Cursor::kTypeCell: + return "cell"; + case Cursor::kTypeContextMenu: + return "context-menu"; + case Cursor::kTypeAlias: + return "alias"; + case Cursor::kTypeProgress: + return "progress"; + case Cursor::kTypeNoDrop: + return "nodrop"; + case Cursor::kTypeCopy: + return "copy"; + case Cursor::kTypeNone: + return "none"; + case Cursor::kTypeNotAllowed: + return "not-allowed"; + case Cursor::kTypeZoomIn: + return "zoom-in"; + case Cursor::kTypeZoomOut: + return "zoom-out"; + case Cursor::kTypeGrab: + return "grab"; + case Cursor::kTypeGrabbing: + return "grabbing"; + case Cursor::kTypeCustom: + return "custom"; + default: + return "default"; } } diff --git a/atom/common/mouse_util.h b/atom/common/mouse_util.h index 4a4d0638f01..efc70eeb7bd 100644 --- a/atom/common/mouse_util.h +++ b/atom/common/mouse_util.h @@ -12,18 +12,17 @@ // IPC macros similar to the already existing ones in the chromium source. // We need these to listen to the cursor change IPC message while still // letting chromium handle the actual cursor change by setting handled = false. -#define IPC_MESSAGE_HANDLER_CODE(msg_class, member_func, code) \ - IPC_MESSAGE_FORWARD_CODE(msg_class, this, \ - _IpcMessageHandlerClass::member_func, code) +#define IPC_MESSAGE_HANDLER_CODE(msg_class, member_func, code) \ + IPC_MESSAGE_FORWARD_CODE(msg_class, this, \ + _IpcMessageHandlerClass::member_func, code) -#define IPC_MESSAGE_FORWARD_CODE(msg_class, obj, member_func, code) \ - case msg_class::ID: { \ - if (!msg_class::Dispatch(&ipc_message__, obj, this, param__, \ - &member_func)) \ - ipc_message__.set_dispatch_error(); \ - code; \ - } \ - break; +#define IPC_MESSAGE_FORWARD_CODE(msg_class, obj, member_func, code) \ + case msg_class::ID: { \ + if (!msg_class::Dispatch(&ipc_message__, obj, this, param__, \ + &member_func)) \ + ipc_message__.set_dispatch_error(); \ + code; \ + } break; namespace atom { diff --git a/atom/common/native_mate_converters/accelerator_converter.cc b/atom/common/native_mate_converters/accelerator_converter.cc index 15eaafda2e3..09583088711 100644 --- a/atom/common/native_mate_converters/accelerator_converter.cc +++ b/atom/common/native_mate_converters/accelerator_converter.cc @@ -11,8 +11,9 @@ namespace mate { // static -bool Converter::FromV8( - v8::Isolate* isolate, v8::Local val, ui::Accelerator* out) { +bool Converter::FromV8(v8::Isolate* isolate, + v8::Local val, + ui::Accelerator* out) { std::string keycode; if (!ConvertFromV8(isolate, val, &keycode)) return false; diff --git a/atom/common/native_mate_converters/accelerator_converter.h b/atom/common/native_mate_converters/accelerator_converter.h index 499077c08e2..f2f6b56e985 100644 --- a/atom/common/native_mate_converters/accelerator_converter.h +++ b/atom/common/native_mate_converters/accelerator_converter.h @@ -13,9 +13,10 @@ class Accelerator; namespace mate { -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, ui::Accelerator* out); }; diff --git a/atom/common/native_mate_converters/blink_converter.cc b/atom/common/native_mate_converters/blink_converter.cc index a3b6eb079ac..f52ec9af2e4 100644 --- a/atom/common/native_mate_converters/blink_converter.cc +++ b/atom/common/native_mate_converters/blink_converter.cc @@ -24,7 +24,7 @@ namespace { -template +template int VectorToBitArray(const std::vector& vec) { int bits = 0; for (const T& item : vec) @@ -36,9 +36,10 @@ int VectorToBitArray(const std::vector& vec) { namespace mate { -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Handle val, + static bool FromV8(v8::Isolate* isolate, + v8::Handle val, base::char16* out) { base::string16 code = base::UTF8ToUTF16(V8ToString(val)); if (code.length() != 1) @@ -48,9 +49,10 @@ struct Converter { } }; -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Handle val, + static bool FromV8(v8::Isolate* isolate, + v8::Handle val, blink::WebInputEvent::Type* out) { std::string type = base::ToLowerASCII(V8ToString(val)); if (type == "mousedown") @@ -85,9 +87,10 @@ struct Converter { } }; -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Handle val, + static bool FromV8(v8::Isolate* isolate, + v8::Handle val, blink::WebMouseEvent::Button* out) { std::string button = base::ToLowerASCII(V8ToString(val)); if (button == "left") @@ -102,9 +105,10 @@ struct Converter { } }; -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Handle val, + static bool FromV8(v8::Isolate* isolate, + v8::Handle val, blink::WebInputEvent::Modifiers* out) { std::string modifier = base::ToLowerASCII(V8ToString(val)); if (modifier == "shift") @@ -138,16 +142,16 @@ struct Converter { }; blink::WebInputEvent::Type GetWebInputEventType(v8::Isolate* isolate, - v8::Local val) { + v8::Local val) { blink::WebInputEvent::Type type = blink::WebInputEvent::kUndefined; mate::Dictionary dict; ConvertFromV8(isolate, val, &dict) && dict.Get("type", &type); return type; } -bool Converter::FromV8( - v8::Isolate* isolate, v8::Local val, - blink::WebInputEvent* out) { +bool Converter::FromV8(v8::Isolate* isolate, + v8::Local val, + blink::WebInputEvent* out) { mate::Dictionary dict; if (!ConvertFromV8(isolate, val, &dict)) return false; @@ -162,9 +166,9 @@ bool Converter::FromV8( return true; } -bool Converter::FromV8( - v8::Isolate* isolate, v8::Local val, - blink::WebKeyboardEvent* out) { +bool Converter::FromV8(v8::Isolate* isolate, + v8::Local val, + blink::WebKeyboardEvent* out) { mate::Dictionary dict; if (!ConvertFromV8(isolate, val, &dict)) return false; @@ -208,7 +212,8 @@ bool Converter::FromV8( } bool Converter::FromV8( - v8::Isolate* isolate, v8::Local val, + v8::Isolate* isolate, + v8::Local val, content::NativeWebKeyboardEvent* out) { mate::Dictionary dict; if (!ConvertFromV8(isolate, val, &dict)) @@ -220,7 +225,8 @@ bool Converter::FromV8( } v8::Local Converter::ToV8( - v8::Isolate* isolate, const content::NativeWebKeyboardEvent& in) { + v8::Isolate* isolate, + const content::NativeWebKeyboardEvent& in) { mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate); if (in.GetType() == blink::WebInputEvent::Type::kRawKeyDown) @@ -229,7 +235,7 @@ v8::Local Converter::ToV8( dict.Set("type", "keyUp"); dict.Set("key", ui::KeycodeConverter::DomKeyToKeyString(in.dom_key)); dict.Set("code", ui::KeycodeConverter::DomCodeToCodeString( - static_cast(in.dom_code))); + static_cast(in.dom_code))); using Modifiers = blink::WebInputEvent::Modifiers; dict.Set("isAutoRepeat", (in.GetModifiers() & Modifiers::kIsAutoRepeat) != 0); @@ -241,8 +247,9 @@ v8::Local Converter::ToV8( return dict.GetHandle(); } -bool Converter::FromV8( - v8::Isolate* isolate, v8::Local val, blink::WebMouseEvent* out) { +bool Converter::FromV8(v8::Isolate* isolate, + v8::Local val, + blink::WebMouseEvent* out) { mate::Dictionary dict; if (!ConvertFromV8(isolate, val, &dict)) return false; @@ -271,7 +278,8 @@ bool Converter::FromV8( } bool Converter::FromV8( - v8::Isolate* isolate, v8::Local val, + v8::Isolate* isolate, + v8::Local val, blink::WebMouseWheelEvent* out) { mate::Dictionary dict; if (!ConvertFromV8(isolate, val, &dict)) @@ -297,32 +305,35 @@ bool Converter::FromV8( return true; } -bool Converter::FromV8( - v8::Isolate* isolate, v8::Local val, blink::WebFloatPoint* out) { +bool Converter::FromV8(v8::Isolate* isolate, + v8::Local val, + blink::WebFloatPoint* out) { mate::Dictionary dict; if (!ConvertFromV8(isolate, val, &dict)) return false; return dict.Get("x", &out->x) && dict.Get("y", &out->y); } -template<> +template <> struct Converter> { - static bool FromV8( - v8::Isolate* isolate, v8::Local val, - base::Optional* out) { + static bool FromV8(v8::Isolate* isolate, + v8::Local val, + base::Optional* out) { mate::Dictionary dict; if (!ConvertFromV8(isolate, val, &dict)) return false; blink::WebPoint point; bool success = dict.Get("x", &point.x) && dict.Get("y", &point.y); - if (!success) return false; + if (!success) + return false; out->emplace(point); return true; } }; -bool Converter::FromV8( - v8::Isolate* isolate, v8::Local val, blink::WebSize* out) { +bool Converter::FromV8(v8::Isolate* isolate, + v8::Local val, + blink::WebSize* out) { mate::Dictionary dict; if (!ConvertFromV8(isolate, val, &dict)) return false; @@ -330,7 +341,8 @@ bool Converter::FromV8( } bool Converter::FromV8( - v8::Isolate* isolate, v8::Local val, + v8::Isolate* isolate, + v8::Local val, blink::WebDeviceEmulationParams* out) { mate::Dictionary dict; if (!ConvertFromV8(isolate, val, &dict)) @@ -355,10 +367,9 @@ bool Converter::FromV8( return true; } -bool Converter::FromV8( - v8::Isolate* isolate, - v8::Local val, - blink::WebFindOptions* out) { +bool Converter::FromV8(v8::Isolate* isolate, + v8::Local val, + blink::WebFindOptions* out) { mate::Dictionary dict; if (!ConvertFromV8(isolate, val, &dict)) return false; @@ -373,7 +384,8 @@ bool Converter::FromV8( // static v8::Local Converter::ToV8( - v8::Isolate* isolate, const blink::WebContextMenuData::MediaType& in) { + v8::Isolate* isolate, + const blink::WebContextMenuData::MediaType& in) { switch (in) { case blink::WebContextMenuData::kMediaTypeImage: return mate::StringToV8(isolate, "image"); @@ -394,8 +406,8 @@ v8::Local Converter::ToV8( // static v8::Local Converter::ToV8( - v8::Isolate* isolate, - const blink::WebContextMenuData::InputFieldType& in) { + v8::Isolate* isolate, + const blink::WebContextMenuData::InputFieldType& in) { switch (in) { case blink::WebContextMenuData::kInputFieldTypePlainText: return mate::StringToV8(isolate, "plainText"); @@ -410,14 +422,10 @@ v8::Local Converter::ToV8( v8::Local EditFlagsToV8(v8::Isolate* isolate, int editFlags) { mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate); - dict.Set("canUndo", - !!(editFlags & blink::WebContextMenuData::kCanUndo)); - dict.Set("canRedo", - !!(editFlags & blink::WebContextMenuData::kCanRedo)); - dict.Set("canCut", - !!(editFlags & blink::WebContextMenuData::kCanCut)); - dict.Set("canCopy", - !!(editFlags & blink::WebContextMenuData::kCanCopy)); + dict.Set("canUndo", !!(editFlags & blink::WebContextMenuData::kCanUndo)); + dict.Set("canRedo", !!(editFlags & blink::WebContextMenuData::kCanRedo)); + dict.Set("canCut", !!(editFlags & blink::WebContextMenuData::kCanCut)); + dict.Set("canCopy", !!(editFlags & blink::WebContextMenuData::kCanCopy)); bool pasteFlag = false; if (editFlags & blink::WebContextMenuData::kCanPaste) { @@ -429,10 +437,9 @@ v8::Local EditFlagsToV8(v8::Isolate* isolate, int editFlags) { } dict.Set("canPaste", pasteFlag); - dict.Set("canDelete", - !!(editFlags & blink::WebContextMenuData::kCanDelete)); + dict.Set("canDelete", !!(editFlags & blink::WebContextMenuData::kCanDelete)); dict.Set("canSelectAll", - !!(editFlags & blink::WebContextMenuData::kCanSelectAll)); + !!(editFlags & blink::WebContextMenuData::kCanSelectAll)); return mate::ConvertToV8(isolate, dict); } @@ -440,21 +447,20 @@ v8::Local EditFlagsToV8(v8::Isolate* isolate, int editFlags) { v8::Local MediaFlagsToV8(v8::Isolate* isolate, int mediaFlags) { mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate); dict.Set("inError", - !!(mediaFlags & blink::WebContextMenuData::kMediaInError)); + !!(mediaFlags & blink::WebContextMenuData::kMediaInError)); dict.Set("isPaused", - !!(mediaFlags & blink::WebContextMenuData::kMediaPaused)); - dict.Set("isMuted", - !!(mediaFlags & blink::WebContextMenuData::kMediaMuted)); + !!(mediaFlags & blink::WebContextMenuData::kMediaPaused)); + dict.Set("isMuted", !!(mediaFlags & blink::WebContextMenuData::kMediaMuted)); dict.Set("hasAudio", - !!(mediaFlags & blink::WebContextMenuData::kMediaHasAudio)); + !!(mediaFlags & blink::WebContextMenuData::kMediaHasAudio)); dict.Set("isLooping", - (mediaFlags & blink::WebContextMenuData::kMediaLoop) != 0); + (mediaFlags & blink::WebContextMenuData::kMediaLoop) != 0); dict.Set("isControlsVisible", - (mediaFlags & blink::WebContextMenuData::kMediaControls) != 0); + (mediaFlags & blink::WebContextMenuData::kMediaControls) != 0); dict.Set("canToggleControls", - !!(mediaFlags & blink::WebContextMenuData::kMediaCanToggleControls)); + !!(mediaFlags & blink::WebContextMenuData::kMediaCanToggleControls)); dict.Set("canRotate", - !!(mediaFlags & blink::WebContextMenuData::kMediaCanRotate)); + !!(mediaFlags & blink::WebContextMenuData::kMediaCanRotate)); return mate::ConvertToV8(isolate, dict); } @@ -483,8 +489,8 @@ v8::Local Converter::ToV8( // static v8::Local Converter::ToV8( - v8::Isolate* isolate, - const blink::WebReferrerPolicy& in) { + v8::Isolate* isolate, + const blink::WebReferrerPolicy& in) { switch (in) { case blink::kWebReferrerPolicyDefault: return mate::StringToV8(isolate, "default"); @@ -508,8 +514,10 @@ v8::Local Converter::ToV8( } // static -bool Converter::FromV8(v8::Isolate* isolate, - v8::Handle val, blink::WebReferrerPolicy* out) { +bool Converter::FromV8( + v8::Isolate* isolate, + v8::Handle val, + blink::WebReferrerPolicy* out) { std::string policy = base::ToLowerASCII(V8ToString(val)); if (policy == "default") *out = blink::kWebReferrerPolicyDefault; diff --git a/atom/common/native_mate_converters/blink_converter.h b/atom/common/native_mate_converters/blink_converter.h index a3f3d063b86..5e6315d9b24 100644 --- a/atom/common/native_mate_converters/blink_converter.h +++ b/atom/common/native_mate_converters/blink_converter.h @@ -10,7 +10,6 @@ #include "third_party/WebKit/public/platform/WebInputEvent.h" #include "third_party/WebKit/public/web/WebContextMenuData.h" - namespace blink { class WebMouseEvent; class WebMouseWheelEvent; @@ -31,99 +30,112 @@ namespace mate { blink::WebInputEvent::Type GetWebInputEventType(v8::Isolate* isolate, v8::Local val); -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, blink::WebInputEvent* out); }; -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, blink::WebKeyboardEvent* out); }; -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, content::NativeWebKeyboardEvent* out); static v8::Local ToV8(v8::Isolate* isolate, const content::NativeWebKeyboardEvent& in); }; -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, blink::WebMouseEvent* out); }; -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, blink::WebMouseWheelEvent* out); }; -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, blink::WebFloatPoint* out); }; -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, blink::WebPoint* out); }; -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, blink::WebSize* out); }; -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, blink::WebDeviceEmulationParams* out); }; -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, blink::WebFindOptions* out); }; -template<> +template <> struct Converter { - static v8::Local ToV8(v8::Isolate* isolate, + static v8::Local ToV8( + v8::Isolate* isolate, const blink::WebContextMenuData::MediaType& in); }; -template<> +template <> struct Converter { - static v8::Local ToV8(v8::Isolate* isolate, + static v8::Local ToV8( + v8::Isolate* isolate, const blink::WebContextMenuData::InputFieldType& in); }; -template<> +template <> struct Converter { static v8::Local ToV8( v8::Isolate* isolate, const blink::WebCache::ResourceTypeStat& stat); }; -template<> +template <> struct Converter { static v8::Local ToV8( v8::Isolate* isolate, const blink::WebCache::ResourceTypeStats& stats); }; -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, - const blink::WebReferrerPolicy& in); - static bool FromV8(v8::Isolate* isolate, v8::Local val, + const blink::WebReferrerPolicy& in); + static bool FromV8(v8::Isolate* isolate, + v8::Local val, blink::WebReferrerPolicy* out); }; diff --git a/atom/common/native_mate_converters/callback.cc b/atom/common/native_mate_converters/callback.cc index 0132ae78582..f33cec720ea 100644 --- a/atom/common/native_mate_converters/callback.cc +++ b/atom/common/native_mate_converters/callback.cc @@ -42,7 +42,7 @@ void CallTranslater(v8::Local external, // Destroy the class on UI thread when possible. struct DeleteOnUIThread { - template + template static void Destruct(const T* x) { if (Locker::IsBrowserProcess() && !BrowserThread::CurrentlyOn(BrowserThread::UI)) { @@ -54,17 +54,14 @@ struct DeleteOnUIThread { }; // Like v8::Global, but ref-counted. -template -class RefCountedGlobal : public base::RefCountedThreadSafe, - DeleteOnUIThread> { +template +class RefCountedGlobal + : public base::RefCountedThreadSafe, DeleteOnUIThread> { public: RefCountedGlobal(v8::Isolate* isolate, v8::Local value) - : handle_(isolate, v8::Local::Cast(value)) { - } + : handle_(isolate, v8::Local::Cast(value)) {} - bool IsAlive() const { - return !handle_.IsEmpty(); - } + bool IsAlive() const { return !handle_.IsEmpty(); } v8::Local NewHandle(v8::Isolate* isolate) const { return v8::Local::New(isolate, handle_); @@ -77,15 +74,12 @@ class RefCountedGlobal : public base::RefCountedThreadSafe, }; SafeV8Function::SafeV8Function(v8::Isolate* isolate, v8::Local value) - : v8_function_(new RefCountedGlobal(isolate, value)) { -} + : v8_function_(new RefCountedGlobal(isolate, value)) {} SafeV8Function::SafeV8Function(const SafeV8Function& other) - : v8_function_(other.v8_function_) { -} + : v8_function_(other.v8_function_) {} -SafeV8Function::~SafeV8Function() { -} +SafeV8Function::~SafeV8Function() {} bool SafeV8Function::IsAlive() const { return v8_function_.get() && v8_function_->IsAlive(); @@ -96,22 +90,20 @@ v8::Local SafeV8Function::NewHandle(v8::Isolate* isolate) const { } v8::Local CreateFunctionFromTranslater( - v8::Isolate* isolate, const Translater& translater) { + v8::Isolate* isolate, + const Translater& translater) { // The FunctionTemplate is cached. if (g_call_translater.IsEmpty()) - g_call_translater.Reset( - isolate, - mate::CreateFunctionTemplate(isolate, base::Bind(&CallTranslater))); + g_call_translater.Reset(isolate, mate::CreateFunctionTemplate( + isolate, base::Bind(&CallTranslater))); v8::Local call_translater = v8::Local::New(isolate, g_call_translater); auto* holder = new TranslaterHolder; holder->translater = translater; - return BindFunctionWith(isolate, - isolate->GetCurrentContext(), - call_translater->GetFunction(), - v8::External::New(isolate, holder), - v8::Object::New(isolate)); + return BindFunctionWith( + isolate, isolate->GetCurrentContext(), call_translater->GetFunction(), + v8::External::New(isolate, holder), v8::Object::New(isolate)); } // func.bind(func, arg1). diff --git a/atom/common/native_mate_converters/callback.h b/atom/common/native_mate_converters/callback.h index 3631e53de1e..06140a3a7a7 100644 --- a/atom/common/native_mate_converters/callback.h +++ b/atom/common/native_mate_converters/callback.h @@ -20,7 +20,7 @@ namespace mate { namespace internal { -template +template class RefCountedGlobal; // Manages the V8 function with RAII. @@ -55,7 +55,7 @@ struct V8FunctionInvoker(ArgTypes...)> { v8::Local holder = function.NewHandle(isolate); v8::Local context = holder->CreationContext(); v8::Context::Scope context_scope(context); - std::vector> args { ConvertToV8(isolate, raw)... }; + std::vector> args{ConvertToV8(isolate, raw)...}; v8::Local ret(holder->Call( holder, args.size(), args.empty() ? nullptr : &args.front())); return handle_scope.Escape(ret); @@ -76,9 +76,8 @@ struct V8FunctionInvoker { v8::Local holder = function.NewHandle(isolate); v8::Local context = holder->CreationContext(); v8::Context::Scope context_scope(context); - std::vector> args { ConvertToV8(isolate, raw)... }; - holder->Call( - holder, args.size(), args.empty() ? nullptr : &args.front()); + std::vector> args{ConvertToV8(isolate, raw)...}; + holder->Call(holder, args.size(), args.empty() ? nullptr : &args.front()); } }; @@ -97,10 +96,10 @@ struct V8FunctionInvoker { v8::Local holder = function.NewHandle(isolate); v8::Local context = holder->CreationContext(); v8::Context::Scope context_scope(context); - std::vector> args { ConvertToV8(isolate, raw)... }; + std::vector> args{ConvertToV8(isolate, raw)...}; v8::Local result; - auto maybe_result = holder->Call( - context, holder, args.size(), args.empty() ? nullptr : &args.front()); + auto maybe_result = holder->Call(context, holder, args.size(), + args.empty() ? nullptr : &args.front()); if (maybe_result.ToLocal(&result)) Converter::FromV8(isolate, result, &ret); return ret; @@ -109,8 +108,8 @@ struct V8FunctionInvoker { // Helper to pass a C++ funtion to JavaScript. using Translater = base::Callback; -v8::Local CreateFunctionFromTranslater( - v8::Isolate* isolate, const Translater& translater); +v8::Local CreateFunctionFromTranslater(v8::Isolate* isolate, + const Translater& translater); v8::Local BindFunctionWith(v8::Isolate* isolate, v8::Local context, v8::Local func, diff --git a/atom/common/native_mate_converters/content_converter.cc b/atom/common/native_mate_converters/content_converter.cc index 2f475731ed4..a74ae403213 100644 --- a/atom/common/native_mate_converters/content_converter.cc +++ b/atom/common/native_mate_converters/content_converter.cc @@ -78,7 +78,8 @@ namespace mate { // static v8::Local Converter::ToV8( - v8::Isolate* isolate, const content::MenuItem::Type& val) { + v8::Isolate* isolate, + const content::MenuItem::Type& val) { switch (val) { case content::MenuItem::CHECKABLE_OPTION: return StringToV8(isolate, "checkbox"); @@ -96,7 +97,8 @@ v8::Local Converter::ToV8( // static v8::Local Converter::ToV8( - v8::Isolate* isolate, const ContextMenuParamsWithWebContents& val) { + v8::Isolate* isolate, + const ContextMenuParamsWithWebContents& val) { const auto& params = val.first; mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate); dict.Set("x", params.x); @@ -109,8 +111,8 @@ v8::Local Converter::ToV8( dict.Set("mediaType", params.media_type); dict.Set("mediaFlags", MediaFlagsToV8(isolate, params.media_flags)); bool has_image_contents = - (params.media_type == blink::WebContextMenuData::kMediaTypeImage) && - params.has_image_contents; + (params.media_type == blink::WebContextMenuData::kMediaTypeImage) && + params.has_image_contents; dict.Set("hasImageContents", has_image_contents); dict.Set("isEditable", params.is_editable); dict.Set("editFlags", EditFlagsToV8(isolate, params.edit_flags)); @@ -119,7 +121,7 @@ v8::Local Converter::ToV8( dict.Set("misspelledWord", params.misspelled_word); dict.Set("frameCharset", params.frame_charset); dict.Set("inputFieldType", params.input_field_type); - dict.Set("menuSourceType", params.source_type); + dict.Set("menuSourceType", params.source_type); if (params.custom_context.is_pepper_menu) dict.Set("menu", MenuToV8(isolate, val.second, params.custom_context, @@ -146,7 +148,8 @@ bool Converter::FromV8( // static v8::Local Converter::ToV8( - v8::Isolate* isolate, const content::PermissionType& val) { + v8::Isolate* isolate, + const content::PermissionType& val) { using PermissionType = atom::WebContentsPermissionHelper::PermissionType; switch (val) { case content::PermissionType::MIDI_SYSEX: @@ -181,10 +184,9 @@ v8::Local Converter::ToV8( } // static -bool Converter::FromV8( - v8::Isolate* isolate, - v8::Local val, - content::StopFindAction* out) { +bool Converter::FromV8(v8::Isolate* isolate, + v8::Local val, + content::StopFindAction* out) { std::string action; if (!ConvertFromV8(isolate, val, &action)) return false; @@ -202,8 +204,7 @@ bool Converter::FromV8( } // static -v8::Local -Converter>::ToV8( +v8::Local Converter>::ToV8( v8::Isolate* isolate, const scoped_refptr& val) { if (!val) @@ -214,9 +215,8 @@ Converter>::ToV8( new base::DictionaryValue); auto type = element.type(); if (type == ResourceRequestBody::Element::TYPE_BYTES) { - std::unique_ptr bytes( - base::Value::CreateWithCopiedBuffer( - element.bytes(), static_cast(element.length()))); + std::unique_ptr bytes(base::Value::CreateWithCopiedBuffer( + element.bytes(), static_cast(element.length()))); post_data_dict->SetString("type", "rawData"); post_data_dict->Set("bytes", std::move(bytes)); } else if (type == ResourceRequestBody::Element::TYPE_FILE) { @@ -284,8 +284,7 @@ bool Converter>::FromV8( dict->GetInteger("file", &length); dict->GetDouble("modificationTime", &modification_time); (*out)->AppendFileSystemFileRange( - GURL(file_system_url), - static_cast(offset), + GURL(file_system_url), static_cast(offset), static_cast(length), base::Time::FromDoubleT(modification_time)); } else if (type == "blob") { @@ -299,17 +298,17 @@ bool Converter>::FromV8( // static v8::Local Converter::ToV8( - v8::Isolate* isolate, content::WebContents* val) { + v8::Isolate* isolate, + content::WebContents* val) { if (!val) return v8::Null(isolate); return atom::api::WebContents::CreateFrom(isolate, val).ToV8(); } // static -bool Converter::FromV8( - v8::Isolate* isolate, - v8::Local val, - content::WebContents** out) { +bool Converter::FromV8(v8::Isolate* isolate, + v8::Local val, + content::WebContents** out) { atom::api::WebContents* web_contents = nullptr; if (!ConvertFromV8(isolate, val, &web_contents) || !web_contents) return false; @@ -320,7 +319,8 @@ bool Converter::FromV8( // static v8::Local Converter::ToV8( - v8::Isolate* isolate, const content::Referrer& val) { + v8::Isolate* isolate, + const content::Referrer& val) { mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate); dict.Set("url", ConvertToV8(isolate, val.url)); dict.Set("policy", ConvertToV8(isolate, val.policy)); @@ -328,10 +328,9 @@ v8::Local Converter::ToV8( } // static -bool Converter::FromV8( - v8::Isolate* isolate, - v8::Local val, - content::Referrer* out) { +bool Converter::FromV8(v8::Isolate* isolate, + v8::Local val, + content::Referrer* out) { mate::Dictionary dict; if (!ConvertFromV8(isolate, val, &dict)) return false; diff --git a/atom/common/native_mate_converters/content_converter.h b/atom/common/native_mate_converters/content_converter.h index c1e34425510..5d269c463c5 100644 --- a/atom/common/native_mate_converters/content_converter.h +++ b/atom/common/native_mate_converters/content_converter.h @@ -18,65 +18,70 @@ namespace content { struct ContextMenuParams; class ResourceRequestBody; class WebContents; -} +} // namespace content using ContextMenuParamsWithWebContents = std::pair; namespace mate { -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, const content::MenuItem::Type& val); }; -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, const ContextMenuParamsWithWebContents& val); }; -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, blink::mojom::PermissionStatus* out); }; -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, const content::PermissionType& val); }; -template<> +template <> struct Converter> { static v8::Local ToV8( v8::Isolate* isolate, const scoped_refptr& val); - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, scoped_refptr* out); }; -template<> +template <> struct Converter { - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, content::StopFindAction* out); }; -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, content::WebContents* val); - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, content::WebContents** out); }; -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, const content::Referrer& val); - static bool FromV8(v8::Isolate* isolate, v8::Local val, + static bool FromV8(v8::Isolate* isolate, + v8::Local val, content::Referrer* out); }; diff --git a/atom/common/native_mate_converters/file_path_converter.h b/atom/common/native_mate_converters/file_path_converter.h index 7df1289e243..c283d3370a6 100644 --- a/atom/common/native_mate_converters/file_path_converter.h +++ b/atom/common/native_mate_converters/file_path_converter.h @@ -12,10 +12,10 @@ namespace mate { -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, - const base::FilePath& val) { + const base::FilePath& val) { return Converter::ToV8(isolate, val.value()); } static bool FromV8(v8::Isolate* isolate, diff --git a/atom/common/native_mate_converters/gfx_converter.cc b/atom/common/native_mate_converters/gfx_converter.cc index 7e214141849..54b7cb71c9f 100644 --- a/atom/common/native_mate_converters/gfx_converter.cc +++ b/atom/common/native_mate_converters/gfx_converter.cc @@ -14,7 +14,7 @@ namespace mate { v8::Local Converter::ToV8(v8::Isolate* isolate, - const gfx::Point& val) { + const gfx::Point& val) { mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); dict.Set("x", val.x()); @@ -58,7 +58,7 @@ bool Converter::FromV8(v8::Isolate* isolate, } v8::Local Converter::ToV8(v8::Isolate* isolate, - const gfx::Rect& val) { + const gfx::Rect& val) { mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); dict.Set("x", val.x()); @@ -75,17 +75,17 @@ bool Converter::FromV8(v8::Isolate* isolate, if (!ConvertFromV8(isolate, val, &dict)) return false; int x, y, width, height; - if (!dict.Get("x", &x) || !dict.Get("y", &y) || - !dict.Get("width", &width) || !dict.Get("height", &height)) + if (!dict.Get("x", &x) || !dict.Get("y", &y) || !dict.Get("width", &width) || + !dict.Get("height", &height)) return false; *out = gfx::Rect(x, y, width, height); return true; } -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, - const display::Display::TouchSupport& val) { + const display::Display::TouchSupport& val) { switch (val) { case display::Display::TOUCH_SUPPORT_AVAILABLE: return StringToV8(isolate, "available"); @@ -98,7 +98,8 @@ struct Converter { }; v8::Local Converter::ToV8( - v8::Isolate* isolate, const display::Display& val) { + v8::Isolate* isolate, + const display::Display& val) { mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); dict.Set("id", val.id()); diff --git a/atom/common/native_mate_converters/gfx_converter.h b/atom/common/native_mate_converters/gfx_converter.h index 1797710962e..705d91b72b5 100644 --- a/atom/common/native_mate_converters/gfx_converter.h +++ b/atom/common/native_mate_converters/gfx_converter.h @@ -15,41 +15,38 @@ namespace gfx { class Point; class Size; class Rect; -} +} // namespace gfx namespace mate { -template<> +template <> struct Converter { - static v8::Local ToV8(v8::Isolate* isolate, - const gfx::Point& val); + static v8::Local ToV8(v8::Isolate* isolate, const gfx::Point& val); static bool FromV8(v8::Isolate* isolate, v8::Local val, gfx::Point* out); }; -template<> +template <> struct Converter { - static v8::Local ToV8(v8::Isolate* isolate, - const gfx::Size& val); + static v8::Local ToV8(v8::Isolate* isolate, const gfx::Size& val); static bool FromV8(v8::Isolate* isolate, v8::Local val, gfx::Size* out); }; -template<> +template <> struct Converter { - static v8::Local ToV8(v8::Isolate* isolate, - const gfx::Rect& val); + static v8::Local ToV8(v8::Isolate* isolate, const gfx::Rect& val); static bool FromV8(v8::Isolate* isolate, v8::Local val, gfx::Rect* out); }; -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, - const display::Display& val); + const display::Display& val); static bool FromV8(v8::Isolate* isolate, v8::Local val, display::Display* out); diff --git a/atom/common/native_mate_converters/gurl_converter.h b/atom/common/native_mate_converters/gurl_converter.h index 34408913b78..110b97d5ef2 100644 --- a/atom/common/native_mate_converters/gurl_converter.h +++ b/atom/common/native_mate_converters/gurl_converter.h @@ -12,10 +12,9 @@ namespace mate { -template<> +template <> struct Converter { - static v8::Local ToV8(v8::Isolate* isolate, - const GURL& val) { + static v8::Local ToV8(v8::Isolate* isolate, const GURL& val) { return ConvertToV8(isolate, val.spec()); } static bool FromV8(v8::Isolate* isolate, diff --git a/atom/common/native_mate_converters/image_converter.cc b/atom/common/native_mate_converters/image_converter.cc index cfb1938a138..11984799260 100644 --- a/atom/common/native_mate_converters/image_converter.cc +++ b/atom/common/native_mate_converters/image_converter.cc @@ -36,7 +36,7 @@ bool Converter::FromV8(v8::Isolate* isolate, } v8::Local Converter::ToV8(v8::Isolate* isolate, - const gfx::Image& val) { + const gfx::Image& val) { return ConvertToV8(isolate, atom::api::NativeImage::Create(isolate, val)); } diff --git a/atom/common/native_mate_converters/image_converter.h b/atom/common/native_mate_converters/image_converter.h index be52288eb04..d8673145a76 100644 --- a/atom/common/native_mate_converters/image_converter.h +++ b/atom/common/native_mate_converters/image_converter.h @@ -10,24 +10,23 @@ namespace gfx { class Image; class ImageSkia; -} +} // namespace gfx namespace mate { -template<> +template <> struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Local val, gfx::ImageSkia* out); }; -template<> +template <> struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Local val, gfx::Image* out); - static v8::Local ToV8(v8::Isolate* isolate, - const gfx::Image& val); + static v8::Local ToV8(v8::Isolate* isolate, const gfx::Image& val); }; } // namespace mate diff --git a/atom/common/native_mate_converters/net_converter.cc b/atom/common/native_mate_converters/net_converter.cc index 618c089ae9a..8e490ca733b 100644 --- a/atom/common/native_mate_converters/net_converter.cc +++ b/atom/common/native_mate_converters/net_converter.cc @@ -29,10 +29,10 @@ namespace mate { namespace { bool CertFromData(const std::string& data, - scoped_refptr* out) { + scoped_refptr* out) { auto cert_list = net::X509Certificate::CreateCertificateListFromBytes( - data.c_str(), data.length(), - net::X509Certificate::FORMAT_SINGLE_CERTIFICATE); + data.c_str(), data.length(), + net::X509Certificate::FORMAT_SINGLE_CERTIFICATE); if (cert_list.empty()) return false; @@ -49,7 +49,8 @@ bool CertFromData(const std::string& data, // static v8::Local Converter::ToV8( - v8::Isolate* isolate, const net::AuthChallengeInfo* val) { + v8::Isolate* isolate, + const net::AuthChallengeInfo* val) { mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate); dict.Set("isProxy", val->is_proxy); dict.Set("scheme", val->scheme); @@ -61,11 +62,11 @@ v8::Local Converter::ToV8( // static v8::Local Converter>::ToV8( - v8::Isolate* isolate, const scoped_refptr& val) { + v8::Isolate* isolate, + const scoped_refptr& val) { mate::Dictionary dict(isolate, v8::Object::New(isolate)); std::string encoded_data; - net::X509Certificate::GetPEMEncoded( - val->os_cert_handle(), &encoded_data); + net::X509Certificate::GetPEMEncoded(val->os_cert_handle(), &encoded_data); dict.Set("data", encoded_data); dict.Set("issuer", val->issuer()); @@ -77,8 +78,8 @@ v8::Local Converter>::ToV8( dict.Set("validStart", val->valid_start().ToDoubleT()); dict.Set("validExpiry", val->valid_expiry().ToDoubleT()); dict.Set("fingerprint", - net::HashValue( - val->CalculateFingerprint256(val->os_cert_handle())).ToString()); + net::HashValue(val->CalculateFingerprint256(val->os_cert_handle())) + .ToString()); if (!val->GetIntermediateCertificates().empty()) { net::X509Certificate::OSCertHandles issuer_intermediates( @@ -86,8 +87,7 @@ v8::Local Converter>::ToV8( val->GetIntermediateCertificates().end()); const scoped_refptr& issuer_cert = net::X509Certificate::CreateFromHandle( - val->GetIntermediateCertificates().front(), - issuer_intermediates); + val->GetIntermediateCertificates().front(), issuer_intermediates); dict.Set("issuerCert", issuer_cert); } @@ -95,7 +95,8 @@ v8::Local Converter>::ToV8( } bool Converter>::FromV8( - v8::Isolate* isolate, v8::Local val, + v8::Isolate* isolate, + v8::Local val, scoped_refptr* out) { mate::Dictionary dict; if (!ConvertFromV8(isolate, val, &dict)) @@ -110,10 +111,10 @@ bool Converter>::FromV8( scoped_refptr parent; if (dict.Get("issuerCert", &parent)) { auto parents = std::vector( - parent->GetIntermediateCertificates()); + parent->GetIntermediateCertificates()); parents.insert(parents.begin(), parent->os_cert_handle()); auto cert = net::X509Certificate::CreateFromHandle( - leaf_cert->os_cert_handle(), parents); + leaf_cert->os_cert_handle(), parents); if (!cert) return false; @@ -127,7 +128,8 @@ bool Converter>::FromV8( // static v8::Local Converter::ToV8( - v8::Isolate* isolate, const net::CertPrincipal& val) { + v8::Isolate* isolate, + const net::CertPrincipal& val) { mate::Dictionary dict(isolate, v8::Object::New(isolate)); dict.Set("commonName", val.common_name); @@ -202,7 +204,8 @@ void FillRequestDetails(base::DictionaryValue* details, const net::URLRequest* request) { details->SetString("method", request->method()); std::string url; - if (!request->url_chain().empty()) url = request->url().spec(); + if (!request->url_chain().empty()) + url = request->url().spec(); details->SetKey("url", base::Value(url)); details->SetString("referrer", request->referrer()); std::unique_ptr list(new base::ListValue); @@ -231,13 +234,11 @@ void GetUploadData(base::ListValue* upload_data_list, if (reader->AsBytesReader()) { const net::UploadBytesElementReader* bytes_reader = reader->AsBytesReader(); - std::unique_ptr bytes( - base::Value::CreateWithCopiedBuffer(bytes_reader->bytes(), - bytes_reader->length())); + std::unique_ptr bytes(base::Value::CreateWithCopiedBuffer( + bytes_reader->bytes(), bytes_reader->length())); upload_data_dict->Set("bytes", std::move(bytes)); } else if (reader->AsFileReader()) { - const net::UploadFileElementReader* file_reader = - reader->AsFileReader(); + const net::UploadFileElementReader* file_reader = reader->AsFileReader(); auto file_path = file_reader->path().AsUTF8Unsafe(); upload_data_dict->SetKey("file", base::Value(file_path)); } else { diff --git a/atom/common/native_mate_converters/net_converter.h b/atom/common/native_mate_converters/net_converter.h index b73ae6ea980..7182102ceba 100644 --- a/atom/common/native_mate_converters/net_converter.h +++ b/atom/common/native_mate_converters/net_converter.h @@ -11,7 +11,7 @@ namespace base { class DictionaryValue; class ListValue; -} +} // namespace base namespace net { class AuthChallengeInfo; @@ -19,19 +19,20 @@ class URLRequest; class X509Certificate; class HttpResponseHeaders; struct CertPrincipal; -} +} // namespace net namespace mate { -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, const net::AuthChallengeInfo* val); }; -template<> +template <> struct Converter> { - static v8::Local ToV8(v8::Isolate* isolate, + static v8::Local ToV8( + v8::Isolate* isolate, const scoped_refptr& val); static bool FromV8(v8::Isolate* isolate, @@ -39,7 +40,7 @@ struct Converter> { scoped_refptr* out); }; -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, const net::CertPrincipal& val); diff --git a/atom/common/native_mate_converters/string16_converter.h b/atom/common/native_mate_converters/string16_converter.h index e2a5b8ca489..a3be221111d 100644 --- a/atom/common/native_mate_converters/string16_converter.h +++ b/atom/common/native_mate_converters/string16_converter.h @@ -10,10 +10,10 @@ namespace mate { -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, - const base::string16& val) { + const base::string16& val) { return MATE_STRING_NEW_FROM_UTF16( isolate, reinterpret_cast(val.data()), val.size()); } @@ -29,9 +29,8 @@ struct Converter { } }; -inline v8::Local StringToV8( - v8::Isolate* isolate, - const base::string16& input) { +inline v8::Local StringToV8(v8::Isolate* isolate, + const base::string16& input) { return ConvertToV8(isolate, input).As(); } diff --git a/atom/common/native_mate_converters/ui_base_types_converter.h b/atom/common/native_mate_converters/ui_base_types_converter.h index ad3390566c8..b5058f50325 100644 --- a/atom/common/native_mate_converters/ui_base_types_converter.h +++ b/atom/common/native_mate_converters/ui_base_types_converter.h @@ -10,7 +10,7 @@ namespace mate { -template<> +template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, const ui::MenuSourceType& in) { diff --git a/atom/common/native_mate_converters/v8_value_converter.cc b/atom/common/native_mate_converters/v8_value_converter.cc index 36a2b345bdd..2e0d594069c 100644 --- a/atom/common/native_mate_converters/v8_value_converter.cc +++ b/atom/common/native_mate_converters/v8_value_converter.cc @@ -32,9 +32,7 @@ class V8ValueConverter::FromV8ValueState { explicit Level(FromV8ValueState* state) : state_(state) { state_->max_recursion_depth_--; } - ~Level() { - state_->max_recursion_depth_++; - } + ~Level() { state_->max_recursion_depth_++; } private: FromV8ValueState* state_; @@ -68,9 +66,7 @@ class V8ValueConverter::FromV8ValueState { return true; } - bool HasReachedMaxRecursionDepth() { - return max_recursion_depth_ < 0; - } + bool HasReachedMaxRecursionDepth() { return max_recursion_depth_ < 0; } private: using HashToHandleMap = std::multimap>; @@ -118,7 +114,7 @@ class V8ValueConverter::ScopedUniquenessGuard { bool is_valid() const { return is_valid_; } private: - typedef std::multimap > HashToHandleMap; + typedef std::multimap> HashToHandleMap; V8ValueConverter::FromV8ValueState* state_; v8::Local value_; bool is_valid_; @@ -149,7 +145,8 @@ void V8ValueConverter::SetDisableNode(bool val) { } v8::Local V8ValueConverter::ToV8Value( - const base::Value* value, v8::Local context) const { + const base::Value* value, + v8::Local context) const { v8::Context::Scope context_scope(context); v8::EscapableHandleScope handle_scope(context->GetIsolate()); return handle_scope.Escape(ToV8ValueImpl(context->GetIsolate(), value)); @@ -165,7 +162,8 @@ base::Value* V8ValueConverter::FromV8Value( } v8::Local V8ValueConverter::ToV8ValueImpl( - v8::Isolate* isolate, const base::Value* value) const { + v8::Isolate* isolate, + const base::Value* value) const { switch (value->GetType()) { case base::Value::Type::NONE: return v8::Null(isolate); @@ -191,8 +189,8 @@ v8::Local V8ValueConverter::ToV8ValueImpl( case base::Value::Type::STRING: { std::string val; value->GetAsString(&val); - return v8::String::NewFromUtf8( - isolate, val.c_str(), v8::String::kNormalString, val.length()); + return v8::String::NewFromUtf8(isolate, val.c_str(), + v8::String::kNormalString, val.length()); } case base::Value::Type::LIST: @@ -203,8 +201,7 @@ v8::Local V8ValueConverter::ToV8ValueImpl( static_cast(value)); case base::Value::Type::BINARY: - return ToArrayBuffer(isolate, - static_cast(value)); + return ToArrayBuffer(isolate, static_cast(value)); default: LOG(ERROR) << "Unexpected value type: " << value->GetType(); @@ -213,7 +210,8 @@ v8::Local V8ValueConverter::ToV8ValueImpl( } v8::Local V8ValueConverter::ToV8Array( - v8::Isolate* isolate, const base::ListValue* val) const { + v8::Isolate* isolate, + const base::ListValue* val) const { v8::Local result(v8::Array::New(isolate, val->GetSize())); for (size_t i = 0; i < val->GetSize(); ++i) { @@ -232,12 +230,13 @@ v8::Local V8ValueConverter::ToV8Array( } v8::Local V8ValueConverter::ToV8Object( - v8::Isolate* isolate, const base::DictionaryValue* val) const { + v8::Isolate* isolate, + const base::DictionaryValue* val) const { mate::Dictionary result = mate::Dictionary::CreateEmpty(isolate); result.SetHidden("simple", true); - for (base::DictionaryValue::Iterator iter(*val); - !iter.IsAtEnd(); iter.Advance()) { + for (base::DictionaryValue::Iterator iter(*val); !iter.IsAtEnd(); + iter.Advance()) { const std::string& key = iter.key(); v8::Local child_v8 = ToV8ValueImpl(isolate, &iter.value()); @@ -253,7 +252,8 @@ v8::Local V8ValueConverter::ToV8Object( } v8::Local V8ValueConverter::ToArrayBuffer( - v8::Isolate* isolate, const base::Value* value) const { + v8::Isolate* isolate, + const base::Value* value) const { const char* data = value->GetBlob().data(); size_t length = value->GetBlob().size(); @@ -282,14 +282,11 @@ v8::Local V8ValueConverter::ToArrayBuffer( mate::Dictionary buffer_class(isolate, buffer_value->ToObject()); v8::Local from_value; - if (!buffer_class.Get("from", &from_value) || - !from_value->IsFunction()) { + if (!buffer_class.Get("from", &from_value) || !from_value->IsFunction()) { return v8::Uint8Array::New(array_buffer, 0, length); } - v8::Local args[] = { - array_buffer - }; + v8::Local args[] = {array_buffer}; auto func = v8::Local::Cast(from_value); auto result = func->Call(context, v8::Null(isolate), 1, args); if (!result.IsEmpty()) { @@ -299,10 +296,9 @@ v8::Local V8ValueConverter::ToArrayBuffer( return v8::Uint8Array::New(array_buffer, 0, length); } -base::Value* V8ValueConverter::FromV8ValueImpl( - FromV8ValueState* state, - v8::Local val, - v8::Isolate* isolate) const { +base::Value* V8ValueConverter::FromV8ValueImpl(FromV8ValueState* state, + v8::Local val, + v8::Isolate* isolate) const { FromV8ValueState::Level state_level(state); if (state->HasReachedMaxRecursionDepth()) return nullptr; @@ -379,10 +375,9 @@ base::Value* V8ValueConverter::FromV8ValueImpl( return nullptr; } -base::Value* V8ValueConverter::FromV8Array( - v8::Local val, - FromV8ValueState* state, - v8::Isolate* isolate) const { +base::Value* V8ValueConverter::FromV8Array(v8::Local val, + FromV8ValueState* state, + v8::Isolate* isolate) const { ScopedUniquenessGuard uniqueness_guard(state, val); if (!uniqueness_guard.is_valid()) return std::make_unique().release(); @@ -419,18 +414,17 @@ base::Value* V8ValueConverter::FromV8Array( return result; } -base::Value* V8ValueConverter::FromNodeBuffer( - v8::Local value, - FromV8ValueState* state, - v8::Isolate* isolate) const { - return base::Value::CreateWithCopiedBuffer( - node::Buffer::Data(value), node::Buffer::Length(value)).release(); +base::Value* V8ValueConverter::FromNodeBuffer(v8::Local value, + FromV8ValueState* state, + v8::Isolate* isolate) const { + return base::Value::CreateWithCopiedBuffer(node::Buffer::Data(value), + node::Buffer::Length(value)) + .release(); } -base::Value* V8ValueConverter::FromV8Object( - v8::Local val, - FromV8ValueState* state, - v8::Isolate* isolate) const { +base::Value* V8ValueConverter::FromV8Object(v8::Local val, + FromV8ValueState* state, + v8::Isolate* isolate) const { ScopedUniquenessGuard uniqueness_guard(state, val); if (!uniqueness_guard.is_valid()) return std::make_unique().release(); @@ -449,9 +443,9 @@ base::Value* V8ValueConverter::FromV8Object( v8::Local key(property_names->Get(i)); // Extend this test to cover more types as necessary and if sensible. - if (!key->IsString() && - !key->IsNumber()) { - NOTREACHED() << "Key \"" << *v8::String::Utf8Value(key) << "\" " + if (!key->IsString() && !key->IsNumber()) { + NOTREACHED() << "Key \"" << *v8::String::Utf8Value(key) + << "\" " "is neither a string nor a number"; continue; } diff --git a/atom/common/native_mate_converters/v8_value_converter.h b/atom/common/native_mate_converters/v8_value_converter.h index ff93e5c462b..8a65317246a 100644 --- a/atom/common/native_mate_converters/v8_value_converter.h +++ b/atom/common/native_mate_converters/v8_value_converter.h @@ -13,7 +13,7 @@ namespace base { class DictionaryValue; class ListValue; class Value; -} +} // namespace base namespace atom { @@ -41,9 +41,8 @@ class V8ValueConverter { v8::Local ToV8Object( v8::Isolate* isolate, const base::DictionaryValue* dictionary) const; - v8::Local ToArrayBuffer( - v8::Isolate* isolate, - const base::Value* value) const; + v8::Local ToArrayBuffer(v8::Isolate* isolate, + const base::Value* value) const; base::Value* FromV8ValueImpl(FromV8ValueState* state, v8::Local value, diff --git a/atom/common/native_mate_converters/value_converter.cc b/atom/common/native_mate_converters/value_converter.cc index 3ed68136709..769965f6445 100644 --- a/atom/common/native_mate_converters/value_converter.cc +++ b/atom/common/native_mate_converters/value_converter.cc @@ -13,8 +13,8 @@ bool Converter::FromV8(v8::Isolate* isolate, v8::Local val, base::DictionaryValue* out) { std::unique_ptr converter(new atom::V8ValueConverter); - std::unique_ptr value(converter->FromV8Value( - val, isolate->GetCurrentContext())); + std::unique_ptr value( + converter->FromV8Value(val, isolate->GetCurrentContext())); if (value && value->IsType(base::Value::Type::DICTIONARY)) { out->Swap(static_cast(value.get())); return true; @@ -34,8 +34,8 @@ bool Converter::FromV8(v8::Isolate* isolate, v8::Local val, base::ListValue* out) { std::unique_ptr converter(new atom::V8ValueConverter); - std::unique_ptr value(converter->FromV8Value( - val, isolate->GetCurrentContext())); + std::unique_ptr value( + converter->FromV8Value(val, isolate->GetCurrentContext())); if (value->IsType(base::Value::Type::LIST)) { out->Swap(static_cast(value.get())); return true; diff --git a/atom/common/native_mate_converters/value_converter.h b/atom/common/native_mate_converters/value_converter.h index 013dd99cc79..a53b2724b08 100644 --- a/atom/common/native_mate_converters/value_converter.h +++ b/atom/common/native_mate_converters/value_converter.h @@ -10,11 +10,11 @@ namespace base { class DictionaryValue; class ListValue; -} +} // namespace base namespace mate { -template<> +template <> struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Local val, @@ -23,7 +23,7 @@ struct Converter { const base::DictionaryValue& val); }; -template<> +template <> struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Local val, diff --git a/atom/common/node_bindings.cc b/atom/common/node_bindings.cc index d9125b420f3..0e13f512f3c 100644 --- a/atom/common/node_bindings.cc +++ b/atom/common/node_bindings.cc @@ -77,11 +77,13 @@ namespace { void stop_and_close_uv_loop(uv_loop_t* loop) { // Close any active handles uv_stop(loop); - uv_walk(loop, [](uv_handle_t* handle, void*){ - if (!uv_is_closing(handle)) { - uv_close(handle, nullptr); - } - }, nullptr); + uv_walk(loop, + [](uv_handle_t* handle, void*) { + if (!uv_is_closing(handle)) { + uv_close(handle, nullptr); + } + }, + nullptr); // Run the loop to let it finish all the closing handles // NB: after uv_stop(), uv_run(UV_RUN_DEFAULT) returns 0 when that's done @@ -102,9 +104,9 @@ namespace { // Convert the given vector to an array of C-strings. The strings in the // returned vector are only guaranteed valid so long as the vector of strings // is not modified. -std::unique_ptr StringVectorToArgArray( +std::unique_ptr StringVectorToArgArray( const std::vector& vector) { - std::unique_ptr array(new const char*[vector.size()]); + std::unique_ptr array(new const char*[vector.size()]); for (size_t i = 0; i < vector.size(); ++i) { array[i] = vector[i].c_str(); } @@ -118,9 +120,10 @@ base::FilePath GetResourcesPath(bool is_browser) { base::FilePath resources_path = #if defined(OS_MACOSX) - is_browser ? exec_path.DirName().DirName().Append("Resources") : - exec_path.DirName().DirName().DirName().DirName().DirName() - .Append("Resources"); + is_browser + ? exec_path.DirName().DirName().Append("Resources") + : exec_path.DirName().DirName().DirName().DirName().DirName().Append( + "Resources"); #else exec_path.DirName().Append(FILE_PATH_LITERAL("resources")); #endif @@ -221,11 +224,11 @@ node::Environment* NodeBindings::CreateEnvironment( base::FilePath resources_path = GetResourcesPath(browser_env_ == BROWSER); base::FilePath script_path = resources_path.Append(FILE_PATH_LITERAL("electron.asar")) - .Append(process_type) - .Append(FILE_PATH_LITERAL("init.js")); + .Append(process_type) + .Append(FILE_PATH_LITERAL("init.js")); args.insert(args.begin() + 1, script_path.AsUTF8Unsafe()); - std::unique_ptr c_argv = StringVectorToArgArray(args); + std::unique_ptr c_argv = StringVectorToArgArray(args); node::Environment* env = node::CreateEnvironment( node::CreateIsolateData(context->GetIsolate(), uv_loop_, platform), context, args.size(), c_argv.get(), 0, nullptr); @@ -324,7 +327,7 @@ void NodeBindings::WakeupEmbedThread() { } // static -void NodeBindings::EmbedThreadRunner(void *arg) { +void NodeBindings::EmbedThreadRunner(void* arg) { NodeBindings* self = static_cast(arg); while (true) { diff --git a/atom/common/node_bindings.h b/atom/common/node_bindings.h index 8f0fdbe5761..00a45b61685 100644 --- a/atom/common/node_bindings.h +++ b/atom/common/node_bindings.h @@ -18,7 +18,7 @@ class MessageLoop; namespace node { class Environment; class MultiIsolatePlatform; -} +} // namespace node namespace atom { @@ -84,7 +84,7 @@ class NodeBindings { private: // Thread to poll uv events. - static void EmbedThreadRunner(void *arg); + static void EmbedThreadRunner(void* arg); // Whether the libuv loop has ended. bool embed_closed_; diff --git a/atom/common/node_bindings_linux.cc b/atom/common/node_bindings_linux.cc index 3ced7029cbc..3c58cb67a07 100644 --- a/atom/common/node_bindings_linux.cc +++ b/atom/common/node_bindings_linux.cc @@ -9,17 +9,15 @@ namespace atom { NodeBindingsLinux::NodeBindingsLinux(BrowserEnvironment browser_env) - : NodeBindings(browser_env), - epoll_(epoll_create(1)) { + : NodeBindings(browser_env), epoll_(epoll_create(1)) { int backend_fd = uv_backend_fd(uv_loop_); - struct epoll_event ev = { 0 }; + struct epoll_event ev = {0}; ev.events = EPOLLIN; ev.data.fd = backend_fd; epoll_ctl(epoll_, EPOLL_CTL_ADD, backend_fd, &ev); } -NodeBindingsLinux::~NodeBindingsLinux() { -} +NodeBindingsLinux::~NodeBindingsLinux() {} void NodeBindingsLinux::RunMessageLoop() { // Get notified when libuv's watcher queue changes. diff --git a/atom/common/node_bindings_mac.cc b/atom/common/node_bindings_mac.cc index e7006a507be..856b9cc868a 100644 --- a/atom/common/node_bindings_mac.cc +++ b/atom/common/node_bindings_mac.cc @@ -15,11 +15,9 @@ namespace atom { NodeBindingsMac::NodeBindingsMac(BrowserEnvironment browser_env) - : NodeBindings(browser_env) { -} + : NodeBindings(browser_env) {} -NodeBindingsMac::~NodeBindingsMac() { -} +NodeBindingsMac::~NodeBindingsMac() {} void NodeBindingsMac::RunMessageLoop() { // Get notified when libuv's watcher queue changes. diff --git a/atom/common/node_bindings_win.cc b/atom/common/node_bindings_win.cc index 419b0ce4c6f..4a5ff5c5140 100644 --- a/atom/common/node_bindings_win.cc +++ b/atom/common/node_bindings_win.cc @@ -15,11 +15,9 @@ extern "C" { namespace atom { NodeBindingsWin::NodeBindingsWin(BrowserEnvironment browser_env) - : NodeBindings(browser_env) { -} + : NodeBindings(browser_env) {} -NodeBindingsWin::~NodeBindingsWin() { -} +NodeBindingsWin::~NodeBindingsWin() {} void NodeBindingsWin::PollEvents() { // If there are other kinds of events pending, uv_backend_timeout will @@ -30,18 +28,11 @@ void NodeBindingsWin::PollEvents() { timeout = uv_backend_timeout(uv_loop_); - GetQueuedCompletionStatus(uv_loop_->iocp, - &bytes, - &key, - &overlapped, - timeout); + GetQueuedCompletionStatus(uv_loop_->iocp, &bytes, &key, &overlapped, timeout); // Give the event back so libuv can deal with it. if (overlapped != NULL) - PostQueuedCompletionStatus(uv_loop_->iocp, - bytes, - key, - overlapped); + PostQueuedCompletionStatus(uv_loop_->iocp, bytes, key, overlapped); } // static diff --git a/atom/common/node_includes.h b/atom/common/node_includes.h index 8fbd0d1beae..19e1ef2670f 100644 --- a/atom/common/node_includes.h +++ b/atom/common/node_includes.h @@ -29,8 +29,8 @@ #undef LIKELY #undef arraysize #undef debug_string // This is defined in macOS 10.9 SDK in AssertMacros.h. -#include "vendor/node/src/env.h" #include "vendor/node/src/env-inl.h" +#include "vendor/node/src/env.h" #include "vendor/node/src/node.h" #include "vendor/node/src/node_buffer.h" #include "vendor/node/src/node_debug_options.h" diff --git a/atom/common/options_switches.cc b/atom/common/options_switches.cc index c1cd185443c..9d62dcfc9f7 100644 --- a/atom/common/options_switches.cc +++ b/atom/common/options_switches.cc @@ -8,26 +8,26 @@ namespace atom { namespace options { -const char kTitle[] = "title"; -const char kIcon[] = "icon"; -const char kFrame[] = "frame"; -const char kShow[] = "show"; -const char kCenter[] = "center"; -const char kX[] = "x"; -const char kY[] = "y"; -const char kWidth[] = "width"; -const char kHeight[] = "height"; -const char kMinWidth[] = "minWidth"; -const char kMinHeight[] = "minHeight"; -const char kMaxWidth[] = "maxWidth"; -const char kMaxHeight[] = "maxHeight"; -const char kResizable[] = "resizable"; -const char kMovable[] = "movable"; -const char kMinimizable[] = "minimizable"; -const char kMaximizable[] = "maximizable"; +const char kTitle[] = "title"; +const char kIcon[] = "icon"; +const char kFrame[] = "frame"; +const char kShow[] = "show"; +const char kCenter[] = "center"; +const char kX[] = "x"; +const char kY[] = "y"; +const char kWidth[] = "width"; +const char kHeight[] = "height"; +const char kMinWidth[] = "minWidth"; +const char kMinHeight[] = "minHeight"; +const char kMaxWidth[] = "maxWidth"; +const char kMaxHeight[] = "maxHeight"; +const char kResizable[] = "resizable"; +const char kMovable[] = "movable"; +const char kMinimizable[] = "minimizable"; +const char kMaximizable[] = "maximizable"; const char kFullScreenable[] = "fullscreenable"; -const char kClosable[] = "closable"; -const char kFullscreen[] = "fullscreen"; +const char kClosable[] = "closable"; +const char kFullscreen[] = "fullscreen"; // Whether the window should show in taskbar. const char kSkipTaskbar[] = "skipTaskbar"; @@ -117,7 +117,7 @@ const char kContextIsolation[] = "contextIsolation"; const char kGuestInstanceID[] = "guestInstanceId"; // Web runtime features. -const char kExperimentalFeatures[] = "experimentalFeatures"; +const char kExperimentalFeatures[] = "experimentalFeatures"; const char kExperimentalCanvasFeatures[] = "experimentalCanvasFeatures"; // Opener window's ID. @@ -182,21 +182,21 @@ const char kAppPath[] = "app-path"; const char kContextId[] = "context-id"; // The command line switch versions of the options. -const char kBackgroundColor[] = "background-color"; -const char kPreloadScript[] = "preload"; -const char kPreloadURL[] = "preload-url"; -const char kPreloadScripts[] = "preload-scripts"; -const char kNodeIntegration[] = "node-integration"; +const char kBackgroundColor[] = "background-color"; +const char kPreloadScript[] = "preload"; +const char kPreloadURL[] = "preload-url"; +const char kPreloadScripts[] = "preload-scripts"; +const char kNodeIntegration[] = "node-integration"; const char kContextIsolation[] = "context-isolation"; -const char kGuestInstanceID[] = "guest-instance-id"; -const char kOpenerID[] = "opener-id"; -const char kScrollBounce[] = "scroll-bounce"; -const char kHiddenPage[] = "hidden-page"; +const char kGuestInstanceID[] = "guest-instance-id"; +const char kOpenerID[] = "opener-id"; +const char kScrollBounce[] = "scroll-bounce"; +const char kHiddenPage[] = "hidden-page"; const char kNativeWindowOpen[] = "native-window-open"; -const char kWebviewTag[] = "webview-tag"; +const char kWebviewTag[] = "webview-tag"; // Command switch passed to renderer process to control nodeIntegration. -const char kNodeIntegrationInWorker[] = "node-integration-in-worker"; +const char kNodeIntegrationInWorker[] = "node-integration-in-worker"; // Widevine options // Path to Widevine CDM binaries. diff --git a/atom/common/options_switches.h b/atom/common/options_switches.h index 9d65bc37692..cdd55e457b8 100644 --- a/atom/common/options_switches.h +++ b/atom/common/options_switches.h @@ -70,8 +70,7 @@ extern const char kNodeIntegrationInWorker[]; extern const char kWebviewTag[]; extern const char kCustomArgs[]; -} // namespace options - +} // namespace options // Following are actually command line switches, should be moved to other files. diff --git a/atom/common/platform_util_linux.cc b/atom/common/platform_util_linux.cc index 76cdfaf45a8..8fad8609342 100644 --- a/atom/common/platform_util_linux.cc +++ b/atom/common/platform_util_linux.cc @@ -19,8 +19,7 @@ namespace { -bool XDGUtilV(const std::vector& argv, - const bool wait_for_exit) { +bool XDGUtilV(const std::vector& argv, const bool wait_for_exit) { base::LaunchOptions options; options.allow_new_privs = true; // xdg-open can fall back on mailcap which eventually might plumb through @@ -91,7 +90,8 @@ bool OpenExternal(const GURL& url, bool activate) { return XDGOpen(url.spec(), false); } -void OpenExternal(const GURL& url, bool activate, +void OpenExternal(const GURL& url, + bool activate, const OpenExternalCallback& callback) { // TODO(gabriel): Implement async open if callback is specified callback.Run(OpenExternal(url, activate) ? "" : "Failed to open"); diff --git a/atom/common/platform_util_win.cc b/atom/common/platform_util_win.cc index ef592020263..947d3bc1a08 100644 --- a/atom/common/platform_util_win.cc +++ b/atom/common/platform_util_win.cc @@ -35,8 +35,8 @@ namespace { // is empty. This function tells if it is. bool ValidateShellCommandForScheme(const std::string& scheme) { base::win::RegKey key; - base::string16 registry_path = base::ASCIIToUTF16(scheme) + - L"\\shell\\open\\command"; + base::string16 registry_path = + base::ASCIIToUTF16(scheme) + L"\\shell\\open\\command"; key.Open(HKEY_CLASSES_ROOT, registry_path.c_str(), KEY_READ); if (!key.Valid()) return false; @@ -60,25 +60,34 @@ class DeleteFileProgressSink : public IFileOperationProgressSink { HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID* ppvObj); HRESULT STDMETHODCALLTYPE StartOperations(void); HRESULT STDMETHODCALLTYPE FinishOperations(HRESULT); - HRESULT STDMETHODCALLTYPE PreRenameItem( - DWORD, IShellItem*, LPCWSTR); - HRESULT STDMETHODCALLTYPE PostRenameItem( - DWORD, IShellItem*, LPCWSTR, HRESULT, IShellItem*); - HRESULT STDMETHODCALLTYPE PreMoveItem( - DWORD, IShellItem*, IShellItem*, LPCWSTR); - HRESULT STDMETHODCALLTYPE PostMoveItem( - DWORD, IShellItem*, IShellItem*, LPCWSTR, HRESULT, IShellItem*); - HRESULT STDMETHODCALLTYPE PreCopyItem( - DWORD, IShellItem*, IShellItem*, LPCWSTR); - HRESULT STDMETHODCALLTYPE PostCopyItem( - DWORD, IShellItem*, IShellItem*, LPCWSTR, HRESULT, IShellItem*); + HRESULT STDMETHODCALLTYPE PreRenameItem(DWORD, IShellItem*, LPCWSTR); + HRESULT STDMETHODCALLTYPE + PostRenameItem(DWORD, IShellItem*, LPCWSTR, HRESULT, IShellItem*); + HRESULT STDMETHODCALLTYPE PreMoveItem(DWORD, + IShellItem*, + IShellItem*, + LPCWSTR); + HRESULT STDMETHODCALLTYPE + PostMoveItem(DWORD, IShellItem*, IShellItem*, LPCWSTR, HRESULT, IShellItem*); + HRESULT STDMETHODCALLTYPE PreCopyItem(DWORD, + IShellItem*, + IShellItem*, + LPCWSTR); + HRESULT STDMETHODCALLTYPE + PostCopyItem(DWORD, IShellItem*, IShellItem*, LPCWSTR, HRESULT, IShellItem*); HRESULT STDMETHODCALLTYPE PreDeleteItem(DWORD, IShellItem*); - HRESULT STDMETHODCALLTYPE PostDeleteItem( - DWORD, IShellItem*, HRESULT, IShellItem*); - HRESULT STDMETHODCALLTYPE PreNewItem( - DWORD, IShellItem*, LPCWSTR); - HRESULT STDMETHODCALLTYPE PostNewItem( - DWORD, IShellItem*, LPCWSTR, LPCWSTR, DWORD, HRESULT, IShellItem*); + HRESULT STDMETHODCALLTYPE PostDeleteItem(DWORD, + IShellItem*, + HRESULT, + IShellItem*); + HRESULT STDMETHODCALLTYPE PreNewItem(DWORD, IShellItem*, LPCWSTR); + HRESULT STDMETHODCALLTYPE PostNewItem(DWORD, + IShellItem*, + LPCWSTR, + LPCWSTR, + DWORD, + HRESULT, + IShellItem*); HRESULT STDMETHODCALLTYPE UpdateProgress(UINT, UINT); HRESULT STDMETHODCALLTYPE ResetTimer(void); HRESULT STDMETHODCALLTYPE PauseTimer(void); @@ -144,43 +153,66 @@ HRESULT DeleteFileProgressSink::PreRenameItem(DWORD, IShellItem*, LPCWSTR) { return S_OK; } -HRESULT DeleteFileProgressSink::PostRenameItem( - DWORD, IShellItem*, __RPC__in_string LPCWSTR, HRESULT, IShellItem*) { +HRESULT DeleteFileProgressSink::PostRenameItem(DWORD, + IShellItem*, + __RPC__in_string LPCWSTR, + HRESULT, + IShellItem*) { return E_NOTIMPL; } -HRESULT DeleteFileProgressSink::PreMoveItem( - DWORD, IShellItem*, IShellItem*, LPCWSTR) { +HRESULT DeleteFileProgressSink::PreMoveItem(DWORD, + IShellItem*, + IShellItem*, + LPCWSTR) { return E_NOTIMPL; } -HRESULT DeleteFileProgressSink::PostMoveItem( - DWORD, IShellItem*, IShellItem*, LPCWSTR, HRESULT, IShellItem*) { +HRESULT DeleteFileProgressSink::PostMoveItem(DWORD, + IShellItem*, + IShellItem*, + LPCWSTR, + HRESULT, + IShellItem*) { return E_NOTIMPL; } -HRESULT DeleteFileProgressSink::PreCopyItem( - DWORD, IShellItem*, IShellItem*, LPCWSTR) { +HRESULT DeleteFileProgressSink::PreCopyItem(DWORD, + IShellItem*, + IShellItem*, + LPCWSTR) { return E_NOTIMPL; } -HRESULT DeleteFileProgressSink::PostCopyItem( - DWORD, IShellItem*, IShellItem*, LPCWSTR, HRESULT, IShellItem*) { +HRESULT DeleteFileProgressSink::PostCopyItem(DWORD, + IShellItem*, + IShellItem*, + LPCWSTR, + HRESULT, + IShellItem*) { return E_NOTIMPL; } -HRESULT DeleteFileProgressSink::PostDeleteItem( - DWORD, IShellItem*, HRESULT, IShellItem*) { +HRESULT DeleteFileProgressSink::PostDeleteItem(DWORD, + IShellItem*, + HRESULT, + IShellItem*) { return S_OK; } -HRESULT DeleteFileProgressSink::PreNewItem( - DWORD dwFlags, IShellItem*, LPCWSTR) { +HRESULT DeleteFileProgressSink::PreNewItem(DWORD dwFlags, + IShellItem*, + LPCWSTR) { return E_NOTIMPL; } -HRESULT DeleteFileProgressSink::PostNewItem( - DWORD, IShellItem*, LPCWSTR, LPCWSTR, DWORD, HRESULT, IShellItem*) { +HRESULT DeleteFileProgressSink::PostNewItem(DWORD, + IShellItem*, + LPCWSTR, + LPCWSTR, + DWORD, + HRESULT, + IShellItem*) { return E_NOTIMPL; } @@ -214,14 +246,12 @@ bool ShowItemInFolder(const base::FilePath& full_path) { if (dir.empty()) return false; - typedef HRESULT (WINAPI *SHOpenFolderAndSelectItemsFuncPtr)( - PCIDLIST_ABSOLUTE pidl_Folder, - UINT cidl, - PCUITEMID_CHILD_ARRAY pidls, + typedef HRESULT(WINAPI * SHOpenFolderAndSelectItemsFuncPtr)( + PCIDLIST_ABSOLUTE pidl_Folder, UINT cidl, PCUITEMID_CHILD_ARRAY pidls, DWORD flags); static SHOpenFolderAndSelectItemsFuncPtr open_folder_and_select_itemsPtr = - NULL; + NULL; static bool initialize_open_folder_proc = true; if (initialize_open_folder_proc) { initialize_open_folder_proc = false; @@ -236,8 +266,8 @@ bool ShowItemInFolder(const base::FilePath& full_path) { return false; } open_folder_and_select_itemsPtr = - reinterpret_cast - (GetProcAddress(shell32_base, "SHOpenFolderAndSelectItems")); + reinterpret_cast( + GetProcAddress(shell32_base, "SHOpenFolderAndSelectItems")); } if (!open_folder_and_select_itemsPtr) { return ui::win::OpenFolderViaShell(dir); @@ -250,21 +280,21 @@ bool ShowItemInFolder(const base::FilePath& full_path) { base::win::ScopedCoMem dir_item; hr = desktop->ParseDisplayName(NULL, NULL, - const_cast(dir.value().c_str()), + const_cast(dir.value().c_str()), NULL, &dir_item, NULL); if (FAILED(hr)) { return ui::win::OpenFolderViaShell(dir); } base::win::ScopedCoMem file_item; - hr = desktop->ParseDisplayName(NULL, NULL, - const_cast(full_path.value().c_str()), - NULL, &file_item, NULL); + hr = desktop->ParseDisplayName( + NULL, NULL, const_cast(full_path.value().c_str()), NULL, + &file_item, NULL); if (FAILED(hr)) { return ui::win::OpenFolderViaShell(dir); } - const ITEMIDLIST* highlight[] = { file_item }; + const ITEMIDLIST* highlight[] = {file_item}; hr = (*open_folder_and_select_itemsPtr)(dir_item, arraysize(highlight), highlight, NULL); @@ -279,13 +309,11 @@ bool ShowItemInFolder(const base::FilePath& full_path) { } else { LPTSTR message = NULL; DWORD message_length = FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - 0, hr, 0, reinterpret_cast(&message), 0, NULL); - LOG(WARNING) << " " << __FUNCTION__ - << "(): Can't open full_path = \"" + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 0, hr, 0, + reinterpret_cast(&message), 0, NULL); + LOG(WARNING) << " " << __FUNCTION__ << "(): Can't open full_path = \"" << full_path.value() << "\"" - << " hr = " << hr - << " " << reinterpret_cast(&message); + << " hr = " << hr << " " << reinterpret_cast(&message); if (message) LocalFree(message); @@ -306,9 +334,9 @@ bool OpenExternal(const base::string16& url, bool activate) { // have been escaped. base::string16 escaped_url = L"\"" + url + L"\""; - if (reinterpret_cast(ShellExecuteW(NULL, L"open", - escaped_url.c_str(), NULL, NULL, - SW_SHOWNORMAL)) <= 32) { + if (reinterpret_cast(ShellExecuteW( + NULL, L"open", escaped_url.c_str(), NULL, NULL, SW_SHOWNORMAL)) <= + 32) { // We fail to execute the call. We could display a message to the user. // TODO(nsylvain): we should also add a dialog to warn on errors. See // bug 1136923. @@ -317,7 +345,8 @@ bool OpenExternal(const base::string16& url, bool activate) { return true; } -void OpenExternal(const base::string16& url, bool activate, +void OpenExternal(const base::string16& url, + bool activate, const OpenExternalCallback& callback) { // TODO(gabriel): Implement async open if callback is specified callback.Run(OpenExternal(url, activate) ? "" : "Failed to open"); @@ -339,19 +368,14 @@ bool MoveItemToTrash(const base::FilePath& path) { if (base::win::GetVersion() >= base::win::VERSION_WIN8) { // Windows 8 introduces the flag RECYCLEONDELETE and deprecates the // ALLOWUNDO in favor of ADDUNDORECORD. - if (FAILED(pfo->SetOperationFlags(FOF_NO_UI | - FOFX_ADDUNDORECORD | - FOF_NOERRORUI | - FOF_SILENT | - FOFX_SHOWELEVATIONPROMPT | - FOFX_RECYCLEONDELETE))) + if (FAILED(pfo->SetOperationFlags( + FOF_NO_UI | FOFX_ADDUNDORECORD | FOF_NOERRORUI | FOF_SILENT | + FOFX_SHOWELEVATIONPROMPT | FOFX_RECYCLEONDELETE))) return false; } else { // For Windows 7 and Vista, RecycleOnDelete is the default behavior. - if (FAILED(pfo->SetOperationFlags(FOF_NO_UI | - FOF_ALLOWUNDO | - FOF_NOERRORUI | - FOF_SILENT | + if (FAILED(pfo->SetOperationFlags(FOF_NO_UI | FOF_ALLOWUNDO | + FOF_NOERRORUI | FOF_SILENT | FOFX_SHOWELEVATIONPROMPT))) return false; } @@ -359,9 +383,8 @@ bool MoveItemToTrash(const base::FilePath& path) { // Create an IShellItem from the supplied source path. base::win::ScopedComPtr delete_item; if (FAILED(SHCreateItemFromParsingName( - path.value().c_str(), - NULL, - IID_PPV_ARGS(delete_item.GetAddressOf())))) + path.value().c_str(), NULL, + IID_PPV_ARGS(delete_item.GetAddressOf())))) return false; base::win::ScopedComPtr delete_sink( diff --git a/atom/node/osfhandle.cc b/atom/node/osfhandle.cc index e5c09d25b53..98fe04624af 100644 --- a/atom/node/osfhandle.cc +++ b/atom/node/osfhandle.cc @@ -23,10 +23,10 @@ #include "third_party/icu/source/i18n/unicode/ucsdet.h" #include "third_party/icu/source/i18n/unicode/ulocdata.h" #include "third_party/icu/source/i18n/unicode/uregex.h" -#include "third_party/icu/source/i18n/unicode/uspoof.h" #include "third_party/icu/source/i18n/unicode/usearch.h" -#include "v8-profiler.h" +#include "third_party/icu/source/i18n/unicode/uspoof.h" #include "v8-inspector.h" +#include "v8-profiler.h" namespace node { @@ -38,8 +38,8 @@ void ReferenceSymbols() { // v8_profiler symbols: v8::TracingCpuProfiler::Create(nullptr); // v8_inspector symbols: - reinterpret_cast(nullptr)-> - canDispatchMethod(v8_inspector::StringView()); + reinterpret_cast(nullptr) + ->canDispatchMethod(v8_inspector::StringView()); reinterpret_cast(nullptr)->unmuteMetrics(0); // icu symbols: u_errorName(U_ZERO_ERROR); @@ -61,8 +61,7 @@ void ReferenceSymbols() { reinterpret_cast(nullptr)->clone(); UParseError parse_error; icu::Transliterator::createFromRules(UnicodeString(), UnicodeString(), - UTRANS_FORWARD, parse_error, - status); + UTRANS_FORWARD, parse_error, status); } } // namespace node diff --git a/atom/renderer/api/atom_api_renderer_ipc.cc b/atom/renderer/api/atom_api_renderer_ipc.cc index dcb59bdb070..dd04c8278d8 100644 --- a/atom/renderer/api/atom_api_renderer_ipc.cc +++ b/atom/renderer/api/atom_api_renderer_ipc.cc @@ -11,8 +11,8 @@ #include "native_mate/dictionary.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" -using content::RenderFrame; using blink::WebLocalFrame; +using content::RenderFrame; namespace atom { @@ -59,8 +59,10 @@ base::string16 SendSync(mate::Arguments* args, return json; } -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { mate::Dictionary dict(context->GetIsolate(), exports); dict.SetMethod("send", &Send); dict.SetMethod("sendSync", &SendSync); diff --git a/atom/renderer/api/atom_api_renderer_ipc.h b/atom/renderer/api/atom_api_renderer_ipc.h index 0f2105ba557..772d543cf6a 100644 --- a/atom/renderer/api/atom_api_renderer_ipc.h +++ b/atom/renderer/api/atom_api_renderer_ipc.h @@ -20,8 +20,10 @@ base::string16 SendSync(mate::Arguments* args, const base::string16& channel, const base::ListValue& arguments); -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv); +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv); } // namespace api diff --git a/atom/renderer/api/atom_api_spell_check_client.cc b/atom/renderer/api/atom_api_spell_check_client.cc index ba0b2c5fd65..1524fd79755 100644 --- a/atom/renderer/api/atom_api_spell_check_client.cc +++ b/atom/renderer/api/atom_api_spell_check_client.cc @@ -13,9 +13,9 @@ #include "chrome/renderer/spellchecker/spellcheck_worditerator.h" #include "native_mate/converter.h" #include "native_mate/dictionary.h" -#include "third_party/icu/source/common/unicode/uscript.h" #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" #include "third_party/WebKit/public/web/WebTextCheckingResult.h" +#include "third_party/icu/source/common/unicode/uscript.h" namespace atom { diff --git a/atom/renderer/api/atom_api_web_frame.cc b/atom/renderer/api/atom_api_web_frame.cc index 68eba204373..3f469ac3cf2 100644 --- a/atom/renderer/api/atom_api_web_frame.cc +++ b/atom/renderer/api/atom_api_web_frame.cc @@ -17,6 +17,7 @@ #include "content/public/renderer/render_view.h" #include "native_mate/dictionary.h" #include "native_mate/object_template_builder.h" +#include "third_party/WebKit/Source/platform/weborigin/SchemeRegistry.h" #include "third_party/WebKit/public/platform/WebCache.h" #include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebElement.h" @@ -27,7 +28,6 @@ #include "third_party/WebKit/public/web/WebScriptExecutionCallback.h" #include "third_party/WebKit/public/web/WebScriptSource.h" #include "third_party/WebKit/public/web/WebView.h" -#include "third_party/WebKit/Source/platform/weborigin/SchemeRegistry.h" #include "atom/common/node_includes.h" @@ -43,8 +43,7 @@ struct Converter { return false; if (execution_type == "asynchronous") { *out = blink::WebLocalFrame::kAsynchronous; - } else if (execution_type == - "asynchronousBlockingOnload") { + } else if (execution_type == "asynchronousBlockingOnload") { *out = blink::WebLocalFrame::kAsynchronousBlockingOnload; } else if (execution_type == "synchronous") { *out = blink::WebLocalFrame::kSynchronous; @@ -66,8 +65,7 @@ namespace { class ScriptExecutionCallback : public blink::WebScriptExecutionCallback { public: using CompletionCallback = - base::Callback& result)>; + base::Callback& result)>; explicit ScriptExecutionCallback(const CompletionCallback& callback) : callback_(callback) {} @@ -123,8 +121,7 @@ WebFrame::WebFrame(v8::Isolate* isolate, blink::WebLocalFrame* blink_frame) Init(isolate); } -WebFrame::~WebFrame() { -} +WebFrame::~WebFrame() {} void WebFrame::SetName(const std::string& name) { web_frame_->SetName(blink::WebString::FromUTF8(name)); @@ -149,8 +146,8 @@ double WebFrame::GetZoomLevel() const { } double WebFrame::SetZoomFactor(double factor) { - return blink::WebView::ZoomLevelToZoomFactor(SetZoomLevel( - blink::WebView::ZoomFactorToZoomLevel(factor))); + return blink::WebView::ZoomLevelToZoomFactor( + SetZoomLevel(blink::WebView::ZoomFactorToZoomLevel(factor))); } double WebFrame::GetZoomFactor() const { @@ -167,7 +164,8 @@ void WebFrame::SetLayoutZoomLevelLimits(double min_level, double max_level) { } v8::Local WebFrame::RegisterEmbedderCustomElement( - const base::string16& name, v8::Local options) { + const base::string16& name, + v8::Local options) { return web_frame_->GetDocument().RegisterEmbedderCustomElement( blink::WebString::FromUTF16(name), options); } @@ -267,12 +265,9 @@ void WebFrame::RegisterURLSchemeAsPrivileged(const std::string& scheme, } void WebFrame::InsertText(const std::string& text) { - web_frame_->FrameWidget() - ->GetActiveWebInputMethodController() - ->CommitText(blink::WebString::FromUTF8(text), - blink::WebVector(), - blink::WebRange(), - 0); + web_frame_->FrameWidget()->GetActiveWebInputMethodController()->CommitText( + blink::WebString::FromUTF8(text), + blink::WebVector(), blink::WebRange(), 0); } void WebFrame::InsertCSS(const std::string& css) { @@ -289,8 +284,7 @@ void WebFrame::ExecuteJavaScript(const base::string16& code, new ScriptExecutionCallback(completion_callback)); web_frame_->RequestExecuteScriptAndReturnValue( blink::WebScriptSource(blink::WebString::FromUTF16(code)), - has_user_gesture, - callback.release()); + has_user_gesture, callback.release()); } void WebFrame::ExecuteJavaScriptInIsolatedWorld( @@ -311,9 +305,9 @@ void WebFrame::ExecuteJavaScriptInIsolatedWorld( return; } - sources.emplace_back(blink::WebScriptSource( - blink::WebString::FromUTF16(code), - blink::WebURL(GURL(url)), start_line)); + sources.emplace_back( + blink::WebScriptSource(blink::WebString::FromUTF16(code), + blink::WebURL(GURL(url)), start_line)); } bool has_user_gesture = false; @@ -333,13 +327,11 @@ void WebFrame::ExecuteJavaScriptInIsolatedWorld( scriptExecutionType, callback.release()); } -void WebFrame::SetIsolatedWorldSecurityOrigin( - int world_id, - const std::string& origin_url) { +void WebFrame::SetIsolatedWorldSecurityOrigin(int world_id, + const std::string& origin_url) { web_frame_->SetIsolatedWorldSecurityOrigin( - world_id, - blink::WebSecurityOrigin::CreateFromString( - blink::WebString::FromUTF8(origin_url))); + world_id, blink::WebSecurityOrigin::CreateFromString( + blink::WebString::FromUTF8(origin_url))); } void WebFrame::SetIsolatedWorldContentSecurityPolicy( @@ -349,9 +341,8 @@ void WebFrame::SetIsolatedWorldContentSecurityPolicy( world_id, blink::WebString::FromUTF8(security_policy)); } -void WebFrame::SetIsolatedWorldHumanReadableName( - int world_id, - const std::string& name) { +void WebFrame::SetIsolatedWorldHumanReadableName(int world_id, + const std::string& name) { web_frame_->SetIsolatedWorldHumanReadableName( world_id, blink::WebString::FromUTF8(name)); } @@ -372,15 +363,15 @@ void WebFrame::ClearCache(v8::Isolate* isolate) { isolate->IdleNotificationDeadline(0.5); blink::WebCache::Clear(); base::MemoryPressureListener::NotifyMemoryPressure( - base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL); + base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL); } v8::Local WebFrame::Opener() const { blink::WebFrame* frame = web_frame_->Opener(); if (frame && frame->IsWebLocalFrame()) return mate::CreateHandle(isolate(), - new WebFrame(isolate(), - frame->ToWebLocalFrame())).ToV8(); + new WebFrame(isolate(), frame->ToWebLocalFrame())) + .ToV8(); else return v8::Null(isolate()); } @@ -389,8 +380,8 @@ v8::Local WebFrame::Parent() const { blink::WebFrame* frame = web_frame_->Parent(); if (frame && frame->IsWebLocalFrame()) return mate::CreateHandle(isolate(), - new WebFrame(isolate(), - frame->ToWebLocalFrame())).ToV8(); + new WebFrame(isolate(), frame->ToWebLocalFrame())) + .ToV8(); else return v8::Null(isolate()); } @@ -399,8 +390,8 @@ v8::Local WebFrame::Top() const { blink::WebFrame* frame = web_frame_->Top(); if (frame && frame->IsWebLocalFrame()) return mate::CreateHandle(isolate(), - new WebFrame(isolate(), - frame->ToWebLocalFrame())).ToV8(); + new WebFrame(isolate(), frame->ToWebLocalFrame())) + .ToV8(); else return v8::Null(isolate()); } @@ -409,8 +400,8 @@ v8::Local WebFrame::FirstChild() const { blink::WebFrame* frame = web_frame_->FirstChild(); if (frame && frame->IsWebLocalFrame()) return mate::CreateHandle(isolate(), - new WebFrame(isolate(), - frame->ToWebLocalFrame())).ToV8(); + new WebFrame(isolate(), frame->ToWebLocalFrame())) + .ToV8(); else return v8::Null(isolate()); } @@ -419,8 +410,8 @@ v8::Local WebFrame::NextSibling() const { blink::WebFrame* frame = web_frame_->NextSibling(); if (frame && frame->IsWebLocalFrame()) return mate::CreateHandle(isolate(), - new WebFrame(isolate(), - frame->ToWebLocalFrame())).ToV8(); + new WebFrame(isolate(), frame->ToWebLocalFrame())) + .ToV8(); else return v8::Null(isolate()); } @@ -432,25 +423,26 @@ v8::Local WebFrame::GetFrameForSelector( blink::WebLocalFrame* element_frame = blink::WebLocalFrame::FromFrameOwnerElement(element); if (element_frame) - return mate::CreateHandle(isolate(), - new WebFrame(isolate(), element_frame)).ToV8(); + return mate::CreateHandle(isolate(), new WebFrame(isolate(), element_frame)) + .ToV8(); else return v8::Null(isolate()); } v8::Local WebFrame::FindFrameByName(const std::string& name) const { - blink::WebLocalFrame* local_frame = web_frame_->FindFrameByName( - blink::WebString::FromUTF8(name))->ToWebLocalFrame(); + blink::WebLocalFrame* local_frame = + web_frame_->FindFrameByName(blink::WebString::FromUTF8(name)) + ->ToWebLocalFrame(); if (local_frame) - return mate::CreateHandle(isolate(), - new WebFrame(isolate(), local_frame)).ToV8(); + return mate::CreateHandle(isolate(), new WebFrame(isolate(), local_frame)) + .ToV8(); else return v8::Null(isolate()); } // static -void WebFrame::BuildPrototype( - v8::Isolate* isolate, v8::Local prototype) { +void WebFrame::BuildPrototype(v8::Isolate* isolate, + v8::Local prototype) { prototype->SetClassName(mate::StringToV8(isolate, "WebFrame")); mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) .SetMethod("setName", &WebFrame::SetName) @@ -505,8 +497,10 @@ namespace { using atom::api::WebFrame; -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { +void Initialize(v8::Local exports, + v8::Local unused, + v8::Local context, + void* priv) { v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary dict(isolate, exports); dict.Set("webFrame", WebFrame::Create(isolate)); diff --git a/atom/renderer/api/atom_api_web_frame.h b/atom/renderer/api/atom_api_web_frame.h index fd6a2c3e585..54cf849009f 100644 --- a/atom/renderer/api/atom_api_web_frame.h +++ b/atom/renderer/api/atom_api_web_frame.h @@ -21,7 +21,7 @@ class WebLocalFrame; namespace mate { class Dictionary; class Arguments; -} +} // namespace mate namespace atom { @@ -52,7 +52,8 @@ class WebFrame : public mate::Wrappable { void SetLayoutZoomLevelLimits(double min_level, double max_level); v8::Local RegisterEmbedderCustomElement( - const base::string16& name, v8::Local options); + const base::string16& name, + v8::Local options); void RegisterElementResizeCallback( int element_instance_id, const GuestViewContainer::ResizeCallback& callback); @@ -87,8 +88,7 @@ class WebFrame : public mate::Wrappable { void SetIsolatedWorldContentSecurityPolicy( int world_id, const std::string& security_policy); - void SetIsolatedWorldHumanReadableName(int world_id, - const std::string& name); + void SetIsolatedWorldHumanReadableName(int world_id, const std::string& name); // Resource related methods blink::WebCache::ResourceTypeStats GetResourceUsage(v8::Isolate* isolate); diff --git a/atom/renderer/atom_autofill_agent.cc b/atom/renderer/atom_autofill_agent.cc index 4182d8c7104..b07b2b6304b 100644 --- a/atom/renderer/atom_autofill_agent.cc +++ b/atom/renderer/atom_autofill_agent.cc @@ -25,8 +25,8 @@ const size_t kMaxDataLength = 1024; const size_t kMaxListSize = 512; void GetDataListSuggestions(const blink::WebInputElement& element, - std::vector* values, - std::vector* labels) { + std::vector* values, + std::vector* labels) { for (const auto& option : element.FilteredDataListOptions()) { values->push_back(option.Value().Utf16()); if (option.Value() != option.Label()) @@ -49,12 +49,11 @@ void TrimStringVectorForIPC(std::vector* strings) { } } // namespace -AutofillAgent::AutofillAgent( - content::RenderFrame* frame) - : content::RenderFrameObserver(frame), - focused_node_was_last_clicked_(false), - was_focused_before_now_(false), - weak_ptr_factory_(this) { +AutofillAgent::AutofillAgent(content::RenderFrame* frame) + : content::RenderFrameObserver(frame), + focused_node_was_last_clicked_(false), + was_focused_before_now_(false), + weak_ptr_factory_(this) { render_frame()->GetWebFrame()->SetAutofillClient(this); } @@ -72,8 +71,7 @@ void AutofillAgent::FocusedNodeChanged(const blink::WebNode&) { HidePopup(); } -void AutofillAgent::TextFieldDidEndEditing( - const blink::WebInputElement&) { +void AutofillAgent::TextFieldDidEndEditing(const blink::WebInputElement&) { HidePopup(); } @@ -125,13 +123,10 @@ void AutofillAgent::DataListOptionsChanged( } AutofillAgent::ShowSuggestionsOptions::ShowSuggestionsOptions() - : autofill_on_empty_values(false), - requires_caret_at_end(false) { -} + : autofill_on_empty_values(false), requires_caret_at_end(false) {} -void AutofillAgent::ShowSuggestions( - const blink::WebFormControlElement& element, - const ShowSuggestionsOptions& options) { +void AutofillAgent::ShowSuggestions(const blink::WebFormControlElement& element, + const ShowSuggestionsOptions& options) { if (!element.IsEnabled() || element.IsReadOnly()) return; const blink::WebInputElement* input_element = ToWebInputElement(&element); @@ -153,8 +148,8 @@ void AutofillAgent::ShowSuggestions( std::vector data_list_values; std::vector data_list_labels; if (input_element) { - GetDataListSuggestions( - *input_element, &data_list_values, &data_list_labels); + GetDataListSuggestions(*input_element, &data_list_values, + &data_list_labels); TrimStringVectorForIPC(&data_list_values); TrimStringVectorForIPC(&data_list_labels); } @@ -175,7 +170,7 @@ bool AutofillAgent::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(AutofillAgent, message) IPC_MESSAGE_HANDLER(AtomAutofillFrameMsg_AcceptSuggestion, - OnAcceptSuggestion) + OnAcceptSuggestion) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -190,21 +185,20 @@ void AutofillAgent::HidePopup() { Send(new AtomAutofillFrameHostMsg_HidePopup(render_frame()->GetRoutingID())); } -void AutofillAgent::ShowPopup( - const blink::WebFormControlElement& element, - const std::vector& values, - const std::vector& labels) { +void AutofillAgent::ShowPopup(const blink::WebFormControlElement& element, + const std::vector& values, + const std::vector& labels) { gfx::RectF bounds = - render_frame()->GetRenderView()->ElementBoundsInWindow(element); - Send(new AtomAutofillFrameHostMsg_ShowPopup( - render_frame()->GetRoutingID(), bounds, values, labels)); + render_frame()->GetRenderView()->ElementBoundsInWindow(element); + Send(new AtomAutofillFrameHostMsg_ShowPopup(render_frame()->GetRoutingID(), + bounds, values, labels)); } void AutofillAgent::OnAcceptSuggestion(base::string16 suggestion) { auto element = render_frame()->GetWebFrame()->GetDocument().FocusedElement(); if (element.IsFormControlElement()) { ToWebInputElement(&element)->SetAutofillValue( - blink::WebString::FromUTF16(suggestion)); + blink::WebString::FromUTF16(suggestion)); } } diff --git a/atom/renderer/atom_render_frame_observer.cc b/atom/renderer/atom_render_frame_observer.cc index 00c85bb3f1a..cbbbc245ec2 100644 --- a/atom/renderer/atom_render_frame_observer.cc +++ b/atom/renderer/atom_render_frame_observer.cc @@ -92,8 +92,8 @@ void AtomRenderFrameObserver::DidCreateScriptContext( if (ShouldNotifyClient(world_id)) renderer_client_->DidCreateScriptContext(context, render_frame_); - if (renderer_client_->isolated_world() && IsMainWorld(world_id) - && render_frame_->IsMainFrame()) { + if (renderer_client_->isolated_world() && IsMainWorld(world_id) && + render_frame_->IsMainFrame()) { CreateIsolatedWorldContext(); renderer_client_->SetupMainWorldOverrides(context); } @@ -136,7 +136,7 @@ void AtomRenderFrameObserver::CreateIsolatedWorldContext() { // Setup document's origin policy in isolated world frame->SetIsolatedWorldSecurityOrigin( - World::ISOLATED_WORLD, frame->GetDocument().GetSecurityOrigin()); + World::ISOLATED_WORLD, frame->GetDocument().GetSecurityOrigin()); // Create initial script context in isolated world blink::WebScriptSource source("void 0"); @@ -196,8 +196,8 @@ void AtomRenderFrameObserver::OnBrowserMessage(bool send_to_all, } void AtomRenderFrameObserver::EmitIPCEvent(blink::WebLocalFrame* frame, - const base::string16& channel, - const base::ListValue& args) { + const base::string16& channel, + const base::ListValue& args) { if (!frame) return; diff --git a/atom/renderer/atom_render_view_observer.cc b/atom/renderer/atom_render_view_observer.cc index 30bd8d004ab..1a425dfa1d4 100644 --- a/atom/renderer/atom_render_view_observer.cc +++ b/atom/renderer/atom_render_view_observer.cc @@ -14,8 +14,7 @@ namespace atom { AtomRenderViewObserver::AtomRenderViewObserver(content::RenderView* render_view) : content::RenderViewObserver(render_view) {} -AtomRenderViewObserver::~AtomRenderViewObserver() { -} +AtomRenderViewObserver::~AtomRenderViewObserver() {} bool AtomRenderViewObserver::OnMessageReceived(const IPC::Message& message) { bool handled = true; diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index 40bcd472606..4fe96aac047 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -39,8 +39,7 @@ bool IsDevToolsExtension(content::RenderFrame* render_frame) { AtomRendererClient::AtomRendererClient() : node_integration_initialized_(false), node_bindings_(NodeBindings::Create(NodeBindings::RENDERER)), - atom_bindings_(new AtomBindings(uv_default_loop())) { -} + atom_bindings_(new AtomBindings(uv_default_loop())) {} AtomRendererClient::~AtomRendererClient() { asar::ClearArchives(); @@ -79,7 +78,8 @@ void AtomRendererClient::RunScriptsAtDocumentEnd( } void AtomRendererClient::DidCreateScriptContext( - v8::Handle context, content::RenderFrame* render_frame) { + v8::Handle context, + content::RenderFrame* render_frame) { // Only allow node integration for the main frame, unless it is a devtools // extension page. if (!render_frame->IsMainFrame() && !IsDevToolsExtension(render_frame)) @@ -120,7 +120,8 @@ void AtomRendererClient::DidCreateScriptContext( } void AtomRendererClient::WillReleaseScriptContext( - v8::Handle context, content::RenderFrame* render_frame) { + v8::Handle context, + content::RenderFrame* render_frame) { injected_frames_.erase(render_frame); node::Environment* env = node::Environment::GetCurrent(context); @@ -187,8 +188,8 @@ void AtomRendererClient::SetupMainWorldOverrides( mate::ConvertToV8(isolate, left)->ToString(), v8::String::Concat(node::isolated_bundle_value.ToStringChecked(isolate), mate::ConvertToV8(isolate, right)->ToString()))); - auto func = v8::Handle::Cast( - script->Run(context).ToLocalChecked()); + auto func = + v8::Handle::Cast(script->Run(context).ToLocalChecked()); auto binding = v8::Object::New(isolate); api::Initialize(binding, v8::Null(isolate), context, nullptr); @@ -206,7 +207,7 @@ void AtomRendererClient::SetupMainWorldOverrides( dict.Set("nativeWindowOpen", command_line->HasSwitch(switches::kNativeWindowOpen)); - v8::Local args[] = { binding }; + v8::Local args[] = {binding}; ignore_result(func->Call(context, v8::Null(isolate), 1, args)); } diff --git a/atom/renderer/atom_renderer_client.h b/atom/renderer/atom_renderer_client.h index 40e7205c3b5..db2efab4b53 100644 --- a/atom/renderer/atom_renderer_client.h +++ b/atom/renderer/atom_renderer_client.h @@ -26,12 +26,10 @@ class AtomRendererClient : public RendererClientBase { virtual ~AtomRendererClient(); // atom::RendererClientBase: - void DidCreateScriptContext( - v8::Handle context, - content::RenderFrame* render_frame) override; - void WillReleaseScriptContext( - v8::Handle context, - content::RenderFrame* render_frame) override; + void DidCreateScriptContext(v8::Handle context, + content::RenderFrame* render_frame) override; + void WillReleaseScriptContext(v8::Handle context, + content::RenderFrame* render_frame) override; void SetupMainWorldOverrides(v8::Handle context) override; private: diff --git a/atom/renderer/atom_sandboxed_renderer_client.cc b/atom/renderer/atom_sandboxed_renderer_client.cc index 35f3f7dfd2c..1a5a56fdd8d 100644 --- a/atom/renderer/atom_sandboxed_renderer_client.cc +++ b/atom/renderer/atom_sandboxed_renderer_client.cc @@ -32,8 +32,8 @@ const std::string kIpcKey = "ipcNative"; const std::string kModuleCacheKey = "native-module-cache"; bool IsDevTools(content::RenderFrame* render_frame) { - return render_frame->GetWebFrame()->GetDocument().Url() - .ProtocolIs("chrome-devtools"); + return render_frame->GetWebFrame()->GetDocument().Url().ProtocolIs( + "chrome-devtools"); } v8::Local GetModuleCache(v8::Isolate* isolate) { @@ -49,8 +49,9 @@ v8::Local GetModuleCache(v8::Isolate* isolate) { } // adapted from node.cc -v8::Local GetBinding(v8::Isolate* isolate, v8::Local key, - mate::Arguments* margs) { +v8::Local GetBinding(v8::Isolate* isolate, + v8::Local key, + mate::Arguments* margs) { v8::Local exports; std::string module_key = mate::V8ToString(key); mate::Dictionary cache(isolate, GetModuleCache(isolate)); @@ -72,7 +73,7 @@ v8::Local GetBinding(v8::Isolate* isolate, v8::Local key, DCHECK_EQ(mod->nm_register_func, nullptr); DCHECK_NE(mod->nm_context_register_func, nullptr); mod->nm_context_register_func(exports, v8::Null(isolate), - isolate->GetCurrentContext(), mod->nm_priv); + isolate->GetCurrentContext(), mod->nm_priv); cache.Set(module_key.c_str(), exports); return exports; } @@ -114,13 +115,10 @@ class AtomSandboxedRenderFrameObserver : public AtomRenderFrameObserver { v8::HandleScope handle_scope(isolate); auto context = frame->MainWorldScriptContext(); v8::Context::Scope context_scope(context); - v8::Local argv[] = { - mate::ConvertToV8(isolate, channel), - v8_converter_->ToV8Value(&args, context) - }; + v8::Local argv[] = {mate::ConvertToV8(isolate, channel), + v8_converter_->ToV8Value(&args, context)}; renderer_client_->InvokeIpcCallback( - context, - "onMessage", + context, "onMessage", std::vector>(argv, argv + 2)); } @@ -132,14 +130,12 @@ class AtomSandboxedRenderFrameObserver : public AtomRenderFrameObserver { } // namespace - AtomSandboxedRendererClient::AtomSandboxedRendererClient() { // Explicitly register electron's builtin modules. NodeBindings::RegisterBuiltinModules(); } -AtomSandboxedRendererClient::~AtomSandboxedRendererClient() { -} +AtomSandboxedRendererClient::~AtomSandboxedRendererClient() {} void AtomSandboxedRendererClient::RenderFrameCreated( content::RenderFrame* render_frame) { @@ -153,16 +149,16 @@ void AtomSandboxedRendererClient::RenderViewCreated( } void AtomSandboxedRendererClient::DidCreateScriptContext( - v8::Handle context, content::RenderFrame* render_frame) { - + v8::Handle context, + content::RenderFrame* render_frame) { // Only allow preload for the main frame or // For devtools we still want to run the preload_bundle script if (!render_frame->IsMainFrame() && !IsDevTools(render_frame)) return; base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); - base::FilePath preload_script_path = command_line->GetSwitchValuePath( - switches::kPreloadScript); + base::FilePath preload_script_path = + command_line->GetSwitchValuePath(switches::kPreloadScript); auto isolate = context->GetIsolate(); v8::HandleScope handle_scope(isolate); @@ -176,23 +172,21 @@ void AtomSandboxedRendererClient::DidCreateScriptContext( mate::ConvertToV8(isolate, left)->ToString(), v8::String::Concat(node::preload_bundle_value.ToStringChecked(isolate), mate::ConvertToV8(isolate, right)->ToString()))); - auto func = v8::Handle::Cast( - script->Run(context).ToLocalChecked()); + auto func = + v8::Handle::Cast(script->Run(context).ToLocalChecked()); // Create and initialize the binding object auto binding = v8::Object::New(isolate); InitializeBindings(binding, context); AddRenderBindings(isolate, binding); v8::Local args[] = { - binding, - mate::ConvertToV8(isolate, preload_script_path.value()) - }; + binding, mate::ConvertToV8(isolate, preload_script_path.value())}; // Execute the function with proper arguments ignore_result(func->Call(context, v8::Null(isolate), 2, args)); } void AtomSandboxedRendererClient::WillReleaseScriptContext( - v8::Handle context, content::RenderFrame* render_frame) { - + v8::Handle context, + content::RenderFrame* render_frame) { // Only allow preload for the main frame if (!render_frame->IsMainFrame()) return; diff --git a/atom/renderer/atom_sandboxed_renderer_client.h b/atom/renderer/atom_sandboxed_renderer_client.h index cadf90a2ae5..c36fbcf6260 100644 --- a/atom/renderer/atom_sandboxed_renderer_client.h +++ b/atom/renderer/atom_sandboxed_renderer_client.h @@ -20,13 +20,11 @@ class AtomSandboxedRendererClient : public RendererClientBase { const std::string& callback_name, std::vector> args); // atom::RendererClientBase: - void DidCreateScriptContext( - v8::Handle context, - content::RenderFrame* render_frame) override; - void WillReleaseScriptContext( - v8::Handle context, - content::RenderFrame* render_frame) override; - void SetupMainWorldOverrides(v8::Handle context) override { } + void DidCreateScriptContext(v8::Handle context, + content::RenderFrame* render_frame) override; + void WillReleaseScriptContext(v8::Handle context, + content::RenderFrame* render_frame) override; + void SetupMainWorldOverrides(v8::Handle context) override {} // content::ContentRendererClient: void RenderFrameCreated(content::RenderFrame*) override; void RenderViewCreated(content::RenderView*) override; diff --git a/atom/renderer/content_settings_observer.cc b/atom/renderer/content_settings_observer.cc index a79ebf37746..e5a50fa5e20 100644 --- a/atom/renderer/content_settings_observer.cc +++ b/atom/renderer/content_settings_observer.cc @@ -17,8 +17,7 @@ ContentSettingsObserver::ContentSettingsObserver( render_frame->GetWebFrame()->SetContentSettingsClient(this); } -ContentSettingsObserver::~ContentSettingsObserver() { -} +ContentSettingsObserver::~ContentSettingsObserver() {} bool ContentSettingsObserver::AllowDatabase( const blink::WebString& name, diff --git a/atom/renderer/guest_view_container.cc b/atom/renderer/guest_view_container.cc index c2c8c00df88..23147cf174e 100644 --- a/atom/renderer/guest_view_container.cc +++ b/atom/renderer/guest_view_container.cc @@ -22,8 +22,7 @@ static base::LazyInstance::DestructorAtExit } // namespace GuestViewContainer::GuestViewContainer(content::RenderFrame* render_frame) - : weak_ptr_factory_(this) { -} + : weak_ptr_factory_(this) {} GuestViewContainer::~GuestViewContainer() { if (element_instance_id_ > 0) diff --git a/atom/renderer/preferences_manager.cc b/atom/renderer/preferences_manager.cc index a9ed710a9db..2c6540cd5f4 100644 --- a/atom/renderer/preferences_manager.cc +++ b/atom/renderer/preferences_manager.cc @@ -13,11 +13,9 @@ PreferencesManager::PreferencesManager() { content::RenderThread::Get()->AddObserver(this); } -PreferencesManager::~PreferencesManager() { -} +PreferencesManager::~PreferencesManager() {} -bool PreferencesManager::OnControlMessageReceived( - const IPC::Message& message) { +bool PreferencesManager::OnControlMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PreferencesManager, message) IPC_MESSAGE_HANDLER(AtomMsg_UpdatePreferences, OnUpdatePreferences) diff --git a/atom/renderer/renderer_client_base.cc b/atom/renderer/renderer_client_base.cc index a061d8c7304..f2efd43bb3d 100644 --- a/atom/renderer/renderer_client_base.cc +++ b/atom/renderer/renderer_client_base.cc @@ -51,7 +51,8 @@ namespace atom { namespace { v8::Local GetRenderProcessPreferences( - const PreferencesManager* preferences_manager, v8::Isolate* isolate) { + const PreferencesManager* preferences_manager, + v8::Isolate* isolate) { if (preferences_manager->preferences()) return mate::ConvertToV8(isolate, *preferences_manager->preferences()); else @@ -61,8 +62,8 @@ v8::Local GetRenderProcessPreferences( std::vector ParseSchemesCLISwitch(const char* switch_name) { base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); std::string custom_schemes = command_line->GetSwitchValueASCII(switch_name); - return base::SplitString( - custom_schemes, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); + return base::SplitString(custom_schemes, ",", base::TRIM_WHITESPACE, + base::SPLIT_WANT_NONEMPTY); } } // namespace @@ -73,12 +74,11 @@ RendererClientBase::RendererClientBase() { ParseSchemesCLISwitch(switches::kStandardSchemes); for (const std::string& scheme : standard_schemes_list) url::AddStandardScheme(scheme.c_str(), url::SCHEME_WITHOUT_PORT); - isolated_world_ = base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kContextIsolation); + isolated_world_ = base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kContextIsolation); } -RendererClientBase::~RendererClientBase() { -} +RendererClientBase::~RendererClientBase() {} void RendererClientBase::AddRenderBindings( v8::Isolate* isolate, @@ -137,7 +137,7 @@ void RendererClientBase::RenderThreadStarted() { base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); bool scroll_bounce = command_line->HasSwitch(switches::kScrollBounce); base::ScopedCFTypeRef rubber_banding_key( - base::SysUTF8ToCFStringRef("NSScrollViewRubberbanding")); + base::SysUTF8ToCFStringRef("NSScrollViewRubberbanding")); CFPreferencesSetAppValue(rubber_banding_key, scroll_bounce ? kCFBooleanTrue : kCFBooleanFalse, kCFPreferencesCurrentApplication); @@ -225,7 +225,8 @@ void RendererClientBase::AddSupportedKeySystems( } v8::Local RendererClientBase::GetContext( - blink::WebLocalFrame* frame, v8::Isolate* isolate) { + blink::WebLocalFrame* frame, + v8::Isolate* isolate) { if (isolated_world()) return frame->WorldScriptContext(isolate, World::ISOLATED_WORLD); else diff --git a/atom/renderer/renderer_client_base.h b/atom/renderer/renderer_client_base.h index ba302e6a344..5c296342cc1 100644 --- a/atom/renderer/renderer_client_base.h +++ b/atom/renderer/renderer_client_base.h @@ -20,18 +20,18 @@ class RendererClientBase : public content::ContentRendererClient { RendererClientBase(); virtual ~RendererClientBase(); - virtual void DidCreateScriptContext( - v8::Handle context, content::RenderFrame* render_frame) = 0; - virtual void WillReleaseScriptContext( - v8::Handle context, content::RenderFrame* render_frame) = 0; + virtual void DidCreateScriptContext(v8::Handle context, + content::RenderFrame* render_frame) = 0; + virtual void WillReleaseScriptContext(v8::Handle context, + content::RenderFrame* render_frame) = 0; virtual void DidClearWindowObject(content::RenderFrame* render_frame); virtual void SetupMainWorldOverrides(v8::Handle context) = 0; bool isolated_world() { return isolated_world_; } // Get the context that the Electron API is running in. - v8::Local GetContext( - blink::WebLocalFrame* frame, v8::Isolate* isolate); + v8::Local GetContext(blink::WebLocalFrame* frame, + v8::Isolate* isolate); protected: void AddRenderBindings(v8::Isolate* isolate, diff --git a/atom/renderer/web_worker_observer.cc b/atom/renderer/web_worker_observer.cc index 0736f4e69fe..a6058ef86c7 100644 --- a/atom/renderer/web_worker_observer.cc +++ b/atom/renderer/web_worker_observer.cc @@ -17,8 +17,9 @@ namespace atom { namespace { -static base::LazyInstance>:: - DestructorAtExit lazy_tls = LAZY_INSTANCE_INITIALIZER; +static base::LazyInstance< + base::ThreadLocalPointer>::DestructorAtExit lazy_tls = + LAZY_INSTANCE_INITIALIZER; } // namespace diff --git a/atom/utility/atom_content_utility_client.cc b/atom/utility/atom_content_utility_client.cc index 56fec10a378..e2a856d53ae 100644 --- a/atom/utility/atom_content_utility_client.cc +++ b/atom/utility/atom_content_utility_client.cc @@ -16,11 +16,9 @@ AtomContentUtilityClient::AtomContentUtilityClient() { #endif } -AtomContentUtilityClient::~AtomContentUtilityClient() { -} +AtomContentUtilityClient::~AtomContentUtilityClient() {} -bool AtomContentUtilityClient::OnMessageReceived( - const IPC::Message& message) { +bool AtomContentUtilityClient::OnMessageReceived(const IPC::Message& message) { #if defined(OS_WIN) for (const auto& handler : handlers_) { if (handler->OnMessageReceived(message))