diff --git a/shell/app/node_main.cc b/shell/app/node_main.cc index 1010471a55ba..dfbc4a8b9ee3 100644 --- a/shell/app/node_main.cc +++ b/shell/app/node_main.cc @@ -102,10 +102,6 @@ void SetCrashKeyStub(const std::string& key, const std::string& value) {} void ClearCrashKeyStub(const std::string& key) {} #endif -} // namespace - -namespace electron { - v8::Local GetParameters(v8::Isolate* isolate) { std::map keys; #if !IS_MAS_BUILD() @@ -114,6 +110,10 @@ v8::Local GetParameters(v8::Isolate* isolate) { return gin::ConvertToV8(isolate, keys); } +} // namespace + +namespace electron { + int NodeMain(int argc, char* argv[]) { bool initialized = base::CommandLine::Init(argc, argv); if (!initialized) { diff --git a/shell/browser/api/electron_api_crash_reporter.cc b/shell/browser/api/electron_api_crash_reporter.cc index 8058838c1dcb..2d2cf673a699 100644 --- a/shell/browser/api/electron_api_crash_reporter.cc +++ b/shell/browser/api/electron_api_crash_reporter.cc @@ -81,6 +81,8 @@ const std::map& GetGlobalCrashKeys() { return GetGlobalCrashKeysMutable(); } +namespace { + bool GetClientIdPath(base::FilePath* path) { if (base::PathService::Get(electron::DIR_CRASH_DUMPS, path)) { *path = path->Append("client_id"); @@ -109,6 +111,8 @@ void WriteClientId(const std::string& client_id) { base::WriteFile(client_id_path, client_id); } +} // namespace + std::string GetClientId() { static base::NoDestructor client_id; if (!client_id->empty()) diff --git a/shell/browser/api/electron_api_desktop_capturer.cc b/shell/browser/api/electron_api_desktop_capturer.cc index 14e6739fd8da..d7b3fecc4754 100644 --- a/shell/browser/api/electron_api_desktop_capturer.cc +++ b/shell/browser/api/electron_api_desktop_capturer.cc @@ -46,6 +46,7 @@ #include "ui/base/cocoa/permissions_utils.h" #endif +namespace { #if BUILDFLAG(IS_LINUX) // Private function in ui/base/x/x11_display_util.cc base::flat_map GetMonitors( @@ -142,8 +143,6 @@ base::flat_map MonitorAtomIdToDisplayId() { } #endif -namespace { - std::unique_ptr MakeWindowCapturer() { #if BUILDFLAG(IS_MAC) if (ShouldUseThumbnailCapturerMac(DesktopMediaList::Type::kWindow)) { diff --git a/shell/browser/electron_browser_client.cc b/shell/browser/electron_browser_client.cc index 9c04627f4ccc..d86874f8dfaf 100644 --- a/shell/browser/electron_browser_client.cc +++ b/shell/browser/electron_browser_client.cc @@ -874,6 +874,8 @@ void ElectronBrowserClient::RenderProcessExited( } } +namespace { + void OnOpenExternal(const GURL& escaped_url, bool allowed) { if (allowed) { platform_util::OpenExternal( @@ -910,6 +912,8 @@ void HandleExternalProtocolInUI( has_user_gesture, url); } +} // namespace + bool ElectronBrowserClient::HandleExternalProtocol( const GURL& url, content::WebContents::Getter web_contents_getter, @@ -1539,6 +1543,7 @@ void ElectronBrowserClient::BindHostReceiverForRenderer( } #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) +namespace { void BindMimeHandlerService( content::RenderFrameHost* frame_host, mojo::PendingReceiver @@ -1567,6 +1572,7 @@ void BindBeforeUnloadControl( return; guest_view->FuseBeforeUnloadControl(std::move(receiver)); } +} // namespace #endif void ElectronBrowserClient::ExposeInterfacesToRenderer( @@ -1706,6 +1712,8 @@ content::UsbDelegate* ElectronBrowserClient::GetUsbDelegate() { return usb_delegate_.get(); } +namespace { + void BindBadgeServiceForServiceWorker( const content::ServiceWorkerVersionBaseInfo& info, mojo::PendingReceiver receiver) { @@ -1720,6 +1728,8 @@ void BindBadgeServiceForServiceWorker( render_process_host, info.scope, std::move(receiver)); } +} // namespace + void ElectronBrowserClient::RegisterBrowserInterfaceBindersForServiceWorker( content::BrowserContext* browser_context, const content::ServiceWorkerVersionBaseInfo& service_worker_version_info, diff --git a/shell/browser/extensions/api/tabs/tabs_api.cc b/shell/browser/extensions/api/tabs/tabs_api.cc index 0db9ec0138b4..d507c0144d54 100644 --- a/shell/browser/extensions/api/tabs/tabs_api.cc +++ b/shell/browser/extensions/api/tabs/tabs_api.cc @@ -468,6 +468,8 @@ ExtensionFunction::ResponseAction TabsSetZoomSettingsFunction::Run() { return RespondNow(NoArguments()); } +namespace { + bool IsKillURL(const GURL& url) { #if DCHECK_IS_ON() // Caller should ensure that |url| is already "fixed up" by @@ -587,6 +589,8 @@ base::expected PrepareURLForNavigation( return url; } +} // namespace + TabsUpdateFunction::TabsUpdateFunction() : web_contents_(nullptr) {} ExtensionFunction::ResponseAction TabsUpdateFunction::Run() { diff --git a/shell/browser/serial/serial_chooser_context.cc b/shell/browser/serial/serial_chooser_context.cc index 998a82474c6a..2604a97f981b 100644 --- a/shell/browser/serial/serial_chooser_context.cc +++ b/shell/browser/serial/serial_chooser_context.cc @@ -37,6 +37,8 @@ constexpr char kUsbDriverKey[] = "usb_driver"; #endif // BUILDFLAG(IS_MAC) #endif // BUILDFLAG(IS_WIN) +namespace { + std::string EncodeToken(const base::UnguessableToken& token) { const uint64_t data[2] = {token.GetHighForSerialization(), token.GetLowForSerialization()}; @@ -81,6 +83,8 @@ base::Value PortInfoToValue(const device::mojom::SerialPortInfo& port) { return base::Value(std::move(value)); } +} // namespace + SerialChooserContext::SerialChooserContext(ElectronBrowserContext* context) : browser_context_(context) {} diff --git a/shell/common/asar/asar_util.cc b/shell/common/asar/asar_util.cc index 54049cfd9801..7a9cb32b8d7c 100644 --- a/shell/common/asar/asar_util.cc +++ b/shell/common/asar/asar_util.cc @@ -45,8 +45,6 @@ bool IsDirectoryCached(const base::FilePath& path) { return is_directory_cache[path] = base::DirectoryExists(path); } -} // namespace - ArchiveMap& GetArchiveCache() { static base::NoDestructor s_archive_map; return *s_archive_map; @@ -57,6 +55,8 @@ base::Lock& GetArchiveCacheLock() { return *lock; } +} // namespace + std::shared_ptr GetOrCreateAsarArchive(const base::FilePath& path) { base::AutoLock auto_lock(GetArchiveCacheLock()); ArchiveMap& map = GetArchiveCache(); diff --git a/shell/common/extensions/electron_extensions_api_provider.cc b/shell/common/extensions/electron_extensions_api_provider.cc index b4d9073aeccf..101f789323ff 100644 --- a/shell/common/extensions/electron_extensions_api_provider.cc +++ b/shell/common/extensions/electron_extensions_api_provider.cc @@ -27,6 +27,7 @@ #include "shell/common/extensions/api/permission_features.h" namespace extensions { +namespace { constexpr APIPermissionInfo::InitInfo permissions_to_register[] = { {mojom::APIPermissionID::kDevtools, "devtools", @@ -51,6 +52,7 @@ base::span GetPermissionAliases() { return base::span(); } +} // namespace } // namespace extensions namespace electron { diff --git a/shell/common/gin_helper/cleaned_up_at_exit.cc b/shell/common/gin_helper/cleaned_up_at_exit.cc index 62127558a491..2632061219ef 100644 --- a/shell/common/gin_helper/cleaned_up_at_exit.cc +++ b/shell/common/gin_helper/cleaned_up_at_exit.cc @@ -11,10 +11,15 @@ namespace gin_helper { +namespace { + std::vector& GetDoomed() { static base::NoDestructor> doomed; return *doomed; } + +} // namespace + CleanedUpAtExit::CleanedUpAtExit() { GetDoomed().emplace_back(this); } diff --git a/shell/common/logging.cc b/shell/common/logging.cc index 47e0d93e2caf..cc6895ae1b2d 100644 --- a/shell/common/logging.cc +++ b/shell/common/logging.cc @@ -41,6 +41,8 @@ base::FilePath GetLogFileName(const base::CommandLine& command_line) { } } +namespace { + bool HasExplicitLogFile(const base::CommandLine& command_line) { std::string filename = command_line.GetSwitchValueASCII(switches::kLogFile); if (filename.empty()) @@ -95,6 +97,8 @@ LoggingDestination DetermineLoggingDestination( return LOG_TO_SYSTEM_DEBUG_LOG | LOG_TO_STDERR; } +} // namespace + void InitElectronLogging(const base::CommandLine& command_line, bool is_preinit) { const std::string process_type =