mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: clang-tidy warnings, pt. 1 (#49083)
* fix: google-readability-casting warning about the uint32_t cast * fix: modernize-use-equals-default warnings * fix: readability-redundant-member-init warning * fix: modernize-make-unique warnings * fix: modernize-use-emplace warning: use emplace_back instead of push_back * refactor: address code review feedback
This commit is contained in:
@@ -52,7 +52,7 @@ namespace electron::api {
|
||||
gin::DeprecatedWrapperInfo GlobalShortcut::kWrapperInfo = {
|
||||
gin::kEmbedderNativeGin};
|
||||
|
||||
GlobalShortcut::GlobalShortcut() {}
|
||||
GlobalShortcut::GlobalShortcut() = default;
|
||||
|
||||
GlobalShortcut::~GlobalShortcut() {
|
||||
UnregisterAll();
|
||||
|
||||
@@ -236,9 +236,8 @@ void ElectronPermissionManager::RequestPermissionsWithDetails(
|
||||
render_frame_host->GetProcess()->GetDeprecatedID());
|
||||
} else if (permission_type == blink::PermissionType::GEOLOCATION) {
|
||||
if (IsGeolocationDisabledViaCommandLine()) {
|
||||
results.push_back(content::PermissionResult(
|
||||
blink::mojom::PermissionStatus::DENIED,
|
||||
content::PermissionStatusSource::UNSPECIFIED));
|
||||
results.emplace_back(blink::mojom::PermissionStatus::DENIED,
|
||||
content::PermissionStatusSource::UNSPECIFIED);
|
||||
continue;
|
||||
} else {
|
||||
ElectronBrowserMainParts::Get()
|
||||
@@ -246,9 +245,8 @@ void ElectronPermissionManager::RequestPermissionsWithDetails(
|
||||
->UserDidOptIntoLocationServices();
|
||||
}
|
||||
}
|
||||
results.push_back(content::PermissionResult(
|
||||
blink::mojom::PermissionStatus::GRANTED,
|
||||
content::PermissionStatusSource::UNSPECIFIED));
|
||||
results.emplace_back(blink::mojom::PermissionStatus::GRANTED,
|
||||
content::PermissionStatusSource::UNSPECIFIED);
|
||||
}
|
||||
std::move(response_callback).Run(results);
|
||||
return;
|
||||
|
||||
@@ -54,7 +54,7 @@ void ExtensionActionAPI::Shutdown() {}
|
||||
// ExtensionActionFunction
|
||||
//
|
||||
|
||||
ExtensionActionFunction::ExtensionActionFunction() {}
|
||||
ExtensionActionFunction::ExtensionActionFunction() = default;
|
||||
|
||||
ExtensionFunction::ResponseAction ExtensionActionFunction::Run() {
|
||||
return RunExtensionAction();
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace extensions {
|
||||
class ElectronGuestViewManagerDelegate
|
||||
: public ExtensionsGuestViewManagerDelegate {
|
||||
public:
|
||||
ElectronGuestViewManagerDelegate() : ExtensionsGuestViewManagerDelegate() {}
|
||||
ElectronGuestViewManagerDelegate() = default;
|
||||
~ElectronGuestViewManagerDelegate() override = default;
|
||||
|
||||
// disable copy
|
||||
|
||||
@@ -241,14 +241,13 @@ void FileSelectHelper::SetFileSelectListenerForTesting(
|
||||
std::unique_ptr<ui::SelectFileDialog::FileTypeInfo>
|
||||
FileSelectHelper::GetFileTypesFromAcceptType(
|
||||
const std::vector<std::u16string>& accept_types) {
|
||||
std::unique_ptr<ui::SelectFileDialog::FileTypeInfo> base_file_type(
|
||||
new ui::SelectFileDialog::FileTypeInfo());
|
||||
auto base_file_type = std::make_unique<ui::SelectFileDialog::FileTypeInfo>();
|
||||
if (accept_types.empty())
|
||||
return base_file_type;
|
||||
|
||||
// Create FileTypeInfo and pre-allocate for the first extension list.
|
||||
std::unique_ptr<ui::SelectFileDialog::FileTypeInfo> file_type(
|
||||
new ui::SelectFileDialog::FileTypeInfo(*base_file_type));
|
||||
auto file_type =
|
||||
std::make_unique<ui::SelectFileDialog::FileTypeInfo>(*base_file_type);
|
||||
file_type->include_all_files = true;
|
||||
file_type->extensions.resize(1);
|
||||
std::vector<base::FilePath::StringType>* extensions =
|
||||
|
||||
@@ -21,7 +21,7 @@ class IDUserData : public base::SupportsUserData::Data {
|
||||
public:
|
||||
explicit IDUserData(int32_t id) : id_(id) {}
|
||||
|
||||
explicit operator int32_t() const { return id_; }
|
||||
[[nodiscard]] auto id() { return id_; }
|
||||
|
||||
private:
|
||||
int32_t id_;
|
||||
@@ -58,7 +58,7 @@ int32_t TrackableObjectBase::GetIDFromWrappedClass(
|
||||
auto* id =
|
||||
static_cast<IDUserData*>(wrapped->GetUserData(kTrackedObjectKey));
|
||||
if (id)
|
||||
return int32_t(*id);
|
||||
return id->id();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace electron {
|
||||
|
||||
ElectronExtensionsRendererClient::ElectronExtensionsRendererClient() {}
|
||||
ElectronExtensionsRendererClient::ElectronExtensionsRendererClient() = default;
|
||||
|
||||
ElectronExtensionsRendererClient::~ElectronExtensionsRendererClient() = default;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user