fix: misc-use-internal-linkage warnings (#44872)
* refactor: fix misc-use-internal-linkage warnings: move impl functions into anonymous namespace so that they're not visible to other compilation units
This commit is contained in:
parent
5ca3f950e9
commit
a92b3944a1
9 changed files with 54 additions and 14 deletions
|
@ -70,6 +70,8 @@ Menu::~Menu() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
bool InvokeBoolMethod(const Menu* menu,
|
bool InvokeBoolMethod(const Menu* menu,
|
||||||
const char* method,
|
const char* method,
|
||||||
int command_id,
|
int command_id,
|
||||||
|
@ -84,6 +86,8 @@ bool InvokeBoolMethod(const Menu* menu,
|
||||||
return gin::ConvertFromV8(isolate, val, &ret) ? ret : default_value;
|
return gin::ConvertFromV8(isolate, val, &ret) ? ret : default_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
bool Menu::IsCommandIdChecked(int command_id) const {
|
bool Menu::IsCommandIdChecked(int command_id) const {
|
||||||
return InvokeBoolMethod(this, "_isCommandIdChecked", command_id);
|
return InvokeBoolMethod(this, "_isCommandIdChecked", command_id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,8 @@
|
||||||
|
|
||||||
namespace electron {
|
namespace electron {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
base::IDMap<api::UtilityProcessWrapper*, base::ProcessId>&
|
base::IDMap<api::UtilityProcessWrapper*, base::ProcessId>&
|
||||||
GetAllUtilityProcessWrappers() {
|
GetAllUtilityProcessWrappers() {
|
||||||
static base::NoDestructor<
|
static base::NoDestructor<
|
||||||
|
@ -52,6 +54,8 @@ GetAllUtilityProcessWrappers() {
|
||||||
return *s_all_utility_process_wrappers;
|
return *s_all_utility_process_wrappers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
namespace api {
|
namespace api {
|
||||||
|
|
||||||
gin::WrapperInfo UtilityProcessWrapper::kWrapperInfo = {
|
gin::WrapperInfo UtilityProcessWrapper::kWrapperInfo = {
|
||||||
|
|
|
@ -100,6 +100,8 @@ using FrameTreeNodeIdMap = std::unordered_map<content::FrameTreeNodeId,
|
||||||
using FrameTokenMap =
|
using FrameTokenMap =
|
||||||
std::map<content::GlobalRenderFrameHostToken, WebFrameMain*>;
|
std::map<content::GlobalRenderFrameHostToken, WebFrameMain*>;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
FrameTreeNodeIdMap& GetFrameTreeNodeIdMap() {
|
FrameTreeNodeIdMap& GetFrameTreeNodeIdMap() {
|
||||||
static base::NoDestructor<FrameTreeNodeIdMap> instance;
|
static base::NoDestructor<FrameTreeNodeIdMap> instance;
|
||||||
return *instance;
|
return *instance;
|
||||||
|
@ -109,6 +111,8 @@ FrameTokenMap& GetFrameTokenMap() {
|
||||||
return *instance;
|
return *instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
// static
|
// static
|
||||||
WebFrameMain* WebFrameMain::FromFrameTreeNodeId(
|
WebFrameMain* WebFrameMain::FromFrameTreeNodeId(
|
||||||
content::FrameTreeNodeId frame_tree_node_id) {
|
content::FrameTreeNodeId frame_tree_node_id) {
|
||||||
|
|
|
@ -87,6 +87,8 @@ void ElectronExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
|
||||||
management_policy_ = std::make_unique<ManagementPolicy>();
|
management_policy_ = std::make_unique<ManagementPolicy>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
std::unique_ptr<base::Value::Dict> ParseManifest(
|
std::unique_ptr<base::Value::Dict> ParseManifest(
|
||||||
const std::string_view manifest_contents) {
|
const std::string_view manifest_contents) {
|
||||||
JSONStringValueDeserializer deserializer(manifest_contents);
|
JSONStringValueDeserializer deserializer(manifest_contents);
|
||||||
|
@ -100,6 +102,8 @@ std::unique_ptr<base::Value::Dict> ParseManifest(
|
||||||
return std::make_unique<base::Value::Dict>(std::move(*manifest).TakeDict());
|
return std::make_unique<base::Value::Dict>(std::move(*manifest).TakeDict());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void ElectronExtensionSystem::LoadComponentExtensions() {
|
void ElectronExtensionSystem::LoadComponentExtensions() {
|
||||||
std::string utf8_error;
|
std::string utf8_error;
|
||||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
|
|
|
@ -79,6 +79,8 @@ bool IsDeviceNameValid(const std::u16string& device_name) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
// Duplicated from chrome/browser/printing/print_view_manager_common.cc
|
// Duplicated from chrome/browser/printing/print_view_manager_common.cc
|
||||||
content::RenderFrameHost* GetFullPagePlugin(content::WebContents* contents) {
|
content::RenderFrameHost* GetFullPagePlugin(content::WebContents* contents) {
|
||||||
content::RenderFrameHost* full_page_plugin = nullptr;
|
content::RenderFrameHost* full_page_plugin = nullptr;
|
||||||
|
@ -98,6 +100,8 @@ content::RenderFrameHost* GetFullPagePlugin(content::WebContents* contents) {
|
||||||
return full_page_plugin;
|
return full_page_plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
// Pick the right RenderFrameHost based on the WebContents.
|
// Pick the right RenderFrameHost based on the WebContents.
|
||||||
// Modified from chrome/browser/printing/print_view_manager_common.cc
|
// Modified from chrome/browser/printing/print_view_manager_common.cc
|
||||||
content::RenderFrameHost* GetRenderFrameHostToUse(
|
content::RenderFrameHost* GetRenderFrameHostToUse(
|
||||||
|
|
|
@ -200,6 +200,8 @@ struct Converter<blink::WebInputEvent::Modifiers> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
std::vector<std::string_view> ModifiersToArray(int modifiers) {
|
std::vector<std::string_view> ModifiersToArray(int modifiers) {
|
||||||
std::vector<std::string_view> modifier_strings;
|
std::vector<std::string_view> modifier_strings;
|
||||||
|
|
||||||
|
@ -210,6 +212,8 @@ std::vector<std::string_view> ModifiersToArray(int modifiers) {
|
||||||
return modifier_strings;
|
return modifier_strings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
blink::WebInputEvent::Type GetWebInputEventType(v8::Isolate* isolate,
|
blink::WebInputEvent::Type GetWebInputEventType(v8::Isolate* isolate,
|
||||||
v8::Local<v8::Value> val) {
|
v8::Local<v8::Value> val) {
|
||||||
blink::WebInputEvent::Type type = blink::WebInputEvent::Type::kUndefined;
|
blink::WebInputEvent::Type type = blink::WebInputEvent::Type::kUndefined;
|
||||||
|
@ -300,6 +304,8 @@ bool Converter<blink::WebKeyboardEvent>::FromV8(v8::Isolate* isolate,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
int GetKeyLocationCode(const blink::WebInputEvent& key) {
|
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
|
// https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/events/keyboard_event.h;l=46;drc=1ff6437e65b183e673b7b4f25060b74dc2ba5c37
|
||||||
enum KeyLocationCode {
|
enum KeyLocationCode {
|
||||||
|
@ -318,6 +324,8 @@ int GetKeyLocationCode(const blink::WebInputEvent& key) {
|
||||||
return kDomKeyLocationStandard;
|
return kDomKeyLocationStandard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
v8::Local<v8::Value> Converter<blink::WebKeyboardEvent>::ToV8(
|
v8::Local<v8::Value> Converter<blink::WebKeyboardEvent>::ToV8(
|
||||||
v8::Isolate* isolate,
|
v8::Isolate* isolate,
|
||||||
const blink::WebKeyboardEvent& in) {
|
const blink::WebKeyboardEvent& in) {
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
namespace platform_util {
|
namespace platform_util {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
struct TrashItemResult {
|
struct TrashItemResult {
|
||||||
bool success;
|
bool success;
|
||||||
std::string error;
|
std::string error;
|
||||||
|
@ -24,6 +26,8 @@ TrashItemResult TrashItemOnBlockingThread(const base::FilePath& full_path) {
|
||||||
return {success, error};
|
return {success, error};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void TrashItem(const base::FilePath& full_path,
|
void TrashItem(const base::FilePath& full_path,
|
||||||
base::OnceCallback<void(bool, const std::string&)> callback) {
|
base::OnceCallback<void(bool, const std::string&)> callback) {
|
||||||
// XXX: is continue_on_shutdown right?
|
// XXX: is continue_on_shutdown right?
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
|
|
||||||
namespace electron::util {
|
namespace electron::util {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
struct ScaleFactorPair {
|
struct ScaleFactorPair {
|
||||||
const char* name;
|
const char* name;
|
||||||
float scale;
|
float scale;
|
||||||
|
@ -55,6 +57,22 @@ float GetScaleFactorFromPath(const base::FilePath& path) {
|
||||||
return 1.0f;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
return AddImageSkiaRepFromBuffer(image, base::as_byte_span(file_contents), 0,
|
||||||
|
0, scale_factor);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
bool AddImageSkiaRepFromPNG(gfx::ImageSkia* image,
|
bool AddImageSkiaRepFromPNG(gfx::ImageSkia* image,
|
||||||
const base::span<const uint8_t> data,
|
const base::span<const uint8_t> data,
|
||||||
double scale_factor) {
|
double scale_factor) {
|
||||||
|
@ -114,20 +132,6 @@ bool AddImageSkiaRepFromBuffer(gfx::ImageSkia* image,
|
||||||
return true;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return AddImageSkiaRepFromBuffer(image, base::as_byte_span(file_contents), 0,
|
|
||||||
0, scale_factor);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PopulateImageSkiaRepsFromPath(gfx::ImageSkia* image,
|
bool PopulateImageSkiaRepsFromPath(gfx::ImageSkia* image,
|
||||||
const base::FilePath& path) {
|
const base::FilePath& path) {
|
||||||
bool succeed = false;
|
bool succeed = false;
|
||||||
|
|
|
@ -659,6 +659,8 @@ v8::MaybeLocal<v8::Object> CreateProxyForAPI(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
void ExposeAPIInWorld(v8::Isolate* isolate,
|
void ExposeAPIInWorld(v8::Isolate* isolate,
|
||||||
const int world_id,
|
const int world_id,
|
||||||
const std::string& key,
|
const std::string& key,
|
||||||
|
@ -819,6 +821,8 @@ bool IsCalledFromMainWorld(v8::Isolate* isolate) {
|
||||||
return isolate->GetCurrentContext() == main_context;
|
return isolate->GetCurrentContext() == main_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
} // namespace api
|
} // namespace api
|
||||||
|
|
||||||
} // namespace electron
|
} // namespace electron
|
||||||
|
|
Loading…
Reference in a new issue