fix: misc-use-internal-linkage warnings (32-x-y) (#45587)

fix: misc-use-internal-linkage warnings (#44843)

* refactor: misc-use-internal-linkage warnings in context bridge

move impl functions into anonymous namespace so that they're not visible
to other compilation units:

- ExposeAPIInWorld()
- IsCalledFromMainWorld()
- OverrideGlobalPropertyFromIsolatedWorld()
- OverrideGlobalValueFromIsolatedWorld()
- TraceKeyPath()

* refactor: misc-use-internal-linkage warnings in skia util

move impl details into anonymous namespace so that they're not visible
to other compilation units:

- struct ScaleFactorPair
- kScaleFactorPairs[]
- GetScaleFactorFromPath()
- AddImageSkiaRepFromPath()

* refactor: misc-use-internal-linkage warnings in printing util

move impl details into anonymous namespace so that they're not visible
to other compilation units:

- GetFullPagePlugin()

* refactor: misc-use-internal-linkage warnings in blijnk converter

move impl details into anonymous namespace so that they're not visible
to other compilation units:

- GetKeyLocationCode()
- ModifiersToArray()

* refactor: misc-use-internal-linkage warnings in extrension system

move impl details into anonymous namespace so that they're not visible
to other compilation units:

- ParseManifest()

* refactor: misc-use-internal-linkage warnings in skia util

move impl details into anonymous namespace so that they're not visible
to other compilation units:

- GetFrameTokenMap()
- GetFrameTreeNodeIdMap()

* refactor: misc-use-internal-linkage warnings in electron_api_utility_process.cc

move impl details into anonymous namespace so that they're not visible
to other compilation units:

- GetAllUtilityProcessWrappers()

* refactor: misc-use-internal-linkage warnings in electron_api_menu

move impl details into anonymous namespace so that they're not visible
to other compilation units:

- InvokeBoolMethod()

* refactor: misc-use-internal-linkage warnings in platform util

move impl details into anonymous namespace so that they're not visible
to other compilation units:

- struct TrashItemResult
- TrashItemOnBlockingThread()
This commit is contained in:
Charles Kerr 2025-02-12 02:46:09 -06:00 committed by GitHub
parent d87805acd2
commit 8c454d7736
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 57 additions and 17 deletions

View file

@ -69,6 +69,8 @@ Menu::~Menu() {
}
}
namespace {
bool InvokeBoolMethod(const Menu* menu,
const char* method,
int command_id,
@ -83,6 +85,8 @@ bool InvokeBoolMethod(const Menu* menu,
return gin::ConvertFromV8(isolate, val, &ret) ? ret : default_value;
}
} // namespace
bool Menu::IsCommandIdChecked(int command_id) const {
return InvokeBoolMethod(this, "_isCommandIdChecked", command_id);
}

View file

@ -45,6 +45,8 @@
namespace electron {
namespace {
base::IDMap<api::UtilityProcessWrapper*, base::ProcessId>&
GetAllUtilityProcessWrappers() {
static base::NoDestructor<
@ -53,6 +55,8 @@ GetAllUtilityProcessWrappers() {
return *s_all_utility_process_wrappers;
}
} // namespace
namespace api {
gin::WrapperInfo UtilityProcessWrapper::kWrapperInfo = {

View file

@ -55,6 +55,8 @@ struct Converter<blink::mojom::PageVisibilityState> {
namespace electron::api {
namespace {
using WebFrameMainIdMap = std::unordered_map<int, WebFrameMain*>;
WebFrameMainIdMap& GetWebFrameMainMap() {
@ -62,6 +64,8 @@ WebFrameMainIdMap& GetWebFrameMainMap() {
return *instance;
}
} // namespace
// static
WebFrameMain* WebFrameMain::FromFrameTreeNodeId(int frame_tree_node_id) {
WebFrameMainIdMap& frame_map = GetWebFrameMainMap();

View file

@ -93,6 +93,8 @@ void ElectronExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
management_policy_ = std::make_unique<ManagementPolicy>();
}
namespace {
std::unique_ptr<base::Value::Dict> ParseManifest(
const std::string_view manifest_contents) {
JSONStringValueDeserializer deserializer(manifest_contents);
@ -106,6 +108,8 @@ std::unique_ptr<base::Value::Dict> ParseManifest(
return std::make_unique<base::Value::Dict>(std::move(*manifest).TakeDict());
}
} // namespace
void ElectronExtensionSystem::LoadComponentExtensions() {
std::string utf8_error;
#if BUILDFLAG(ENABLE_PDF_VIEWER)

View file

@ -76,6 +76,8 @@ bool IsDeviceNameValid(const std::u16string& device_name) {
#endif
}
namespace {
// Duplicated from chrome/browser/printing/print_view_manager_common.cc
content::RenderFrameHost* GetFullPagePlugin(content::WebContents* contents) {
content::RenderFrameHost* full_page_plugin = nullptr;
@ -95,6 +97,8 @@ content::RenderFrameHost* GetFullPagePlugin(content::WebContents* contents) {
return full_page_plugin;
}
} // namespace
// Pick the right RenderFrameHost based on the WebContents.
// Modified from chrome/browser/printing/print_view_manager_common.cc
content::RenderFrameHost* GetRenderFrameHostToUse(

View file

@ -200,6 +200,8 @@ struct Converter<blink::WebInputEvent::Modifiers> {
}
};
namespace {
std::vector<std::string_view> ModifiersToArray(int modifiers) {
std::vector<std::string_view> modifier_strings;
@ -210,6 +212,8 @@ std::vector<std::string_view> ModifiersToArray(int modifiers) {
return modifier_strings;
}
} // namespace
blink::WebInputEvent::Type GetWebInputEventType(v8::Isolate* isolate,
v8::Local<v8::Value> val) {
blink::WebInputEvent::Type type = blink::WebInputEvent::Type::kUndefined;
@ -300,6 +304,8 @@ bool Converter<blink::WebKeyboardEvent>::FromV8(v8::Isolate* isolate,
return true;
}
namespace {
int GetKeyLocationCode(const blink::WebInputEvent& key) {
// https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/events/keyboard_event.h;l=46;drc=1ff6437e65b183e673b7b4f25060b74dc2ba5c37
enum KeyLocationCode {
@ -318,6 +324,8 @@ int GetKeyLocationCode(const blink::WebInputEvent& key) {
return kDomKeyLocationStandard;
}
} // namespace
v8::Local<v8::Value> Converter<blink::WebKeyboardEvent>::ToV8(
v8::Isolate* isolate,
const blink::WebKeyboardEvent& in) {

View file

@ -14,6 +14,8 @@
namespace platform_util {
namespace {
struct TrashItemResult {
bool success;
std::string error;
@ -25,6 +27,8 @@ TrashItemResult TrashItemOnBlockingThread(const base::FilePath& full_path) {
return {success, error};
}
} // namespace
void TrashItem(const base::FilePath& full_path,
base::OnceCallback<void(bool, const std::string&)> callback) {
// XXX: is continue_on_shutdown right?

View file

@ -30,6 +30,8 @@
namespace electron::util {
namespace {
struct ScaleFactorPair {
const char* name;
float scale;
@ -56,6 +58,25 @@ float GetScaleFactorFromPath(const base::FilePath& path) {
return 1.0f;
}
bool AddImageSkiaRepFromPath(gfx::ImageSkia* image,
const base::FilePath& path,
double scale_factor) {
std::string file_contents;
{
electron::ScopedAllowBlockingForElectron allow_blocking;
if (!asar::ReadFileToString(path, &file_contents))
return false;
}
const auto* data =
reinterpret_cast<const unsigned char*>(file_contents.data());
size_t size = file_contents.size();
return AddImageSkiaRepFromBuffer(image, data, size, 0, 0, scale_factor);
}
} // namespace
bool AddImageSkiaRepFromPNG(gfx::ImageSkia* image,
const unsigned char* data,
size_t size,
@ -118,23 +139,6 @@ bool AddImageSkiaRepFromBuffer(gfx::ImageSkia* image,
return true;
}
bool AddImageSkiaRepFromPath(gfx::ImageSkia* image,
const base::FilePath& path,
double scale_factor) {
std::string file_contents;
{
electron::ScopedAllowBlockingForElectron allow_blocking;
if (!asar::ReadFileToString(path, &file_contents))
return false;
}
const auto* data =
reinterpret_cast<const unsigned char*>(file_contents.data());
size_t size = file_contents.size();
return AddImageSkiaRepFromBuffer(image, data, size, 0, 0, scale_factor);
}
bool PopulateImageSkiaRepsFromPath(gfx::ImageSkia* image,
const base::FilePath& path) {
bool succeed = false;

View file

@ -660,6 +660,8 @@ v8::MaybeLocal<v8::Object> CreateProxyForAPI(
}
}
namespace {
void ExposeAPIInWorld(v8::Isolate* isolate,
const int world_id,
const std::string& key,
@ -820,6 +822,8 @@ bool IsCalledFromMainWorld(v8::Isolate* isolate) {
return isolate->GetCurrentContext() == main_context;
}
} // namespace
} // namespace api
} // namespace electron