refactor: move impl functions into private namespace (#43407)
* refactor: move into unnamed namespace: IsKillURL() refactor: move into unnamed namespace: ResolvePossiblyRelativeURL() refactor: move into unnamed namespace: AllowFileAccess() refactor: move into unnamed namespace: PrepareURLForNavigation() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: move into unnamed namespace: GetMonitors() refactor: move into unnamed namespace: GetEDIDProperty() refactor: move into unnamed namespace: MonitorAtomIdToDisplayId() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: move into unnamed namespace: GetPermissionInfos() } refactor: move into unnamed namespace: GetPermissionAliases() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: move into unnamed namespace: OnOpenExternal() refactor: move into unnamed namespace: HandleExternalProtocolInUI() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: move into unnamed namespace: BindMimeHandlerService() refactor: move into unnamed namespace: BindBeforeUnloadControl() refactor: move into unnamed namespace: BindBadgeServiceForServiceWorker() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: move into unnamed namespace: GetClientIdPath() refactor: move into unnamed namespace: ReadClientId() refactor: move into unnamed namespace: WriteClientId() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: move into unnamed namespace: HasExplicitLogFile() refactor: move into unnamed namespace: DetermineLoggingDestination() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: move into unnamed namespace: GetArchiveCache() refactor: move into unnamed namespace: GetArchiveCacheLock() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: move into unnamed namespace: GetParameters() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: move into unnamed namespace: GetDoomed() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: move into unnamed namespace: EncodeToken() refactor: move into unnamed namespace: PortInfoToValue() Co-authored-by: Charles Kerr <charles@charleskerr.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
parent
c50fa5486e
commit
b8a8fe115f
10 changed files with 40 additions and 8 deletions
|
@ -104,10 +104,6 @@ void SetCrashKeyStub(const std::string& key, const std::string& value) {}
|
|||
void ClearCrashKeyStub(const std::string& key) {}
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace electron {
|
||||
|
||||
v8::Local<v8::Value> GetParameters(v8::Isolate* isolate) {
|
||||
std::map<std::string, std::string> keys;
|
||||
#if !IS_MAS_BUILD()
|
||||
|
@ -116,6 +112,10 @@ v8::Local<v8::Value> 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) {
|
||||
|
|
|
@ -83,6 +83,8 @@ const std::map<std::string, std::string>& GetGlobalCrashKeys() {
|
|||
return GetGlobalCrashKeysMutable();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
bool GetClientIdPath(base::FilePath* path) {
|
||||
if (base::PathService::Get(electron::DIR_CRASH_DUMPS, path)) {
|
||||
*path = path->Append("client_id");
|
||||
|
@ -111,6 +113,8 @@ void WriteClientId(const std::string& client_id) {
|
|||
base::WriteFile(client_id_path, client_id);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::string GetClientId() {
|
||||
static base::NoDestructor<std::string> client_id;
|
||||
if (!client_id->empty())
|
||||
|
|
|
@ -45,6 +45,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<x11::RandR::Output, int> GetMonitors(
|
||||
|
@ -141,8 +142,6 @@ base::flat_map<int32_t, uint32_t> MonitorAtomIdToDisplayId() {
|
|||
}
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
std::unique_ptr<ThumbnailCapturer> MakeWindowCapturer() {
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
if (ShouldUseThumbnailCapturerMac(DesktopMediaList::Type::kWindow)) {
|
||||
|
|
|
@ -885,6 +885,8 @@ void ElectronBrowserClient::RenderProcessExited(
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
void OnOpenExternal(const GURL& escaped_url, bool allowed) {
|
||||
if (allowed) {
|
||||
platform_util::OpenExternal(
|
||||
|
@ -921,6 +923,8 @@ void HandleExternalProtocolInUI(
|
|||
has_user_gesture, url);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool ElectronBrowserClient::HandleExternalProtocol(
|
||||
const GURL& url,
|
||||
content::WebContents::Getter web_contents_getter,
|
||||
|
@ -1538,6 +1542,7 @@ void ElectronBrowserClient::BindHostReceiverForRenderer(
|
|||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
||||
namespace {
|
||||
void BindMimeHandlerService(
|
||||
content::RenderFrameHost* frame_host,
|
||||
mojo::PendingReceiver<extensions::mime_handler::MimeHandlerService>
|
||||
|
@ -1566,6 +1571,7 @@ void BindBeforeUnloadControl(
|
|||
return;
|
||||
guest_view->FuseBeforeUnloadControl(std::move(receiver));
|
||||
}
|
||||
} // namespace
|
||||
#endif
|
||||
|
||||
void ElectronBrowserClient::ExposeInterfacesToRenderer(
|
||||
|
@ -1705,6 +1711,8 @@ content::UsbDelegate* ElectronBrowserClient::GetUsbDelegate() {
|
|||
return usb_delegate_.get();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
void BindBadgeServiceForServiceWorker(
|
||||
const content::ServiceWorkerVersionBaseInfo& info,
|
||||
mojo::PendingReceiver<blink::mojom::BadgeService> receiver) {
|
||||
|
@ -1719,6 +1727,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,
|
||||
|
|
|
@ -466,6 +466,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
|
||||
|
@ -585,6 +587,8 @@ base::expected<GURL, std::string> PrepareURLForNavigation(
|
|||
return url;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TabsUpdateFunction::TabsUpdateFunction() : web_contents_(nullptr) {}
|
||||
|
||||
ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
|
||||
|
|
|
@ -36,6 +36,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()};
|
||||
|
@ -80,6 +82,8 @@ base::Value PortInfoToValue(const device::mojom::SerialPortInfo& port) {
|
|||
return base::Value(std::move(value));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
SerialChooserContext::SerialChooserContext(ElectronBrowserContext* context)
|
||||
: browser_context_(context) {}
|
||||
|
||||
|
|
|
@ -46,8 +46,6 @@ bool IsDirectoryCached(const base::FilePath& path) {
|
|||
return is_directory_cache[path] = base::DirectoryExists(path);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
ArchiveMap& GetArchiveCache() {
|
||||
static base::NoDestructor<ArchiveMap> s_archive_map;
|
||||
return *s_archive_map;
|
||||
|
@ -58,6 +56,8 @@ base::Lock& GetArchiveCacheLock() {
|
|||
return *lock;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::shared_ptr<Archive> GetOrCreateAsarArchive(const base::FilePath& path) {
|
||||
base::AutoLock auto_lock(GetArchiveCacheLock());
|
||||
ArchiveMap& map = GetArchiveCache();
|
||||
|
|
|
@ -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<const Alias> GetPermissionAliases() {
|
|||
return base::span<const Alias>();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace extensions
|
||||
|
||||
namespace electron {
|
||||
|
|
|
@ -11,10 +11,15 @@
|
|||
|
||||
namespace gin_helper {
|
||||
|
||||
namespace {
|
||||
|
||||
std::vector<CleanedUpAtExit*>& GetDoomed() {
|
||||
static base::NoDestructor<std::vector<CleanedUpAtExit*>> doomed;
|
||||
return *doomed;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
CleanedUpAtExit::CleanedUpAtExit() {
|
||||
GetDoomed().emplace_back(this);
|
||||
}
|
||||
|
|
|
@ -42,6 +42,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())
|
||||
|
@ -96,6 +98,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 =
|
||||
|
|
Loading…
Reference in a new issue