refactor: replace remaining NULL with nullptr (#40053)

refactor: use nullptr everywhere
This commit is contained in:
Milan Burda 2023-10-03 21:26:35 +02:00 committed by GitHub
parent 9d0e6d09f0
commit 04b2ba84cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 98 additions and 93 deletions

View file

@ -60,7 +60,7 @@ int main(int argc, char* argv[]) {
#if defined(HELPER_EXECUTABLE) && !IS_MAS_BUILD()
uint32_t exec_path_size = 0;
int rv = _NSGetExecutablePath(NULL, &exec_path_size);
int rv = _NSGetExecutablePath(nullptr, &exec_path_size);
if (rv != -1) {
FatalError("_NSGetExecutablePath: get length failed.");
}

View file

@ -63,7 +63,7 @@ void App::SetActivationPolicy(gin_helper::ErrorThrower thrower,
bool App::IsRunningUnderARM64Translation() const {
int proc_translated = 0;
size_t size = sizeof(proc_translated);
if (sysctlbyname("sysctl.proc_translated", &proc_translated, &size, NULL,
if (sysctlbyname("sysctl.proc_translated", &proc_translated, &size, nullptr,
0) == -1) {
return false;
}

View file

@ -132,7 +132,7 @@ struct Converter<electron::ElectronMenuModel*> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
electron::ElectronMenuModel** out) {
// null would be transferred to NULL.
// null would be transferred to nullptr.
if (val->IsNull()) {
*out = nullptr;
return true;

View file

@ -27,8 +27,8 @@ void PowerMonitor::InitPlatformSpecificMonitors() {
WNDCLASSEX window_class;
base::win::InitializeWindowClass(
kPowerMonitorWindowClass,
&base::win::WrappedWindowProc<PowerMonitor::WndProcStatic>, 0, 0, 0, NULL,
NULL, NULL, NULL, NULL, &window_class);
&base::win::WrappedWindowProc<PowerMonitor::WndProcStatic>, 0, 0, 0,
nullptr, nullptr, nullptr, nullptr, nullptr, &window_class);
instance_ = window_class.hInstance;
atom_ = RegisterClassEx(&window_class);

View file

@ -171,7 +171,7 @@ void SystemPreferences::InitializeWindow() {
base::win::InitializeWindowClass(
kSystemPreferencesWindowClass,
&base::win::WrappedWindowProc<SystemPreferences::WndProcStatic>, 0, 0, 0,
NULL, NULL, NULL, NULL, NULL, &window_class);
nullptr, nullptr, nullptr, nullptr, nullptr, &window_class);
instance_ = window_class.hInstance;
atom_ = RegisterClassEx(&window_class);

View file

@ -4,8 +4,8 @@
// This interface is for managing the global services of the application. Each
// service is lazily created when requested the first time. The service getters
// will return NULL if the service is not available, so callers must check for
// this condition.
// will return nullptr if the service is not available, so callers must check
// for this condition.
#ifndef ELECTRON_SHELL_BROWSER_BROWSER_PROCESS_IMPL_H_
#define ELECTRON_SHELL_BROWSER_BROWSER_PROCESS_IMPL_H_
@ -35,7 +35,7 @@ class PrintJobManager;
class BackgroundModeManager {};
// NOT THREAD SAFE, call only from the main thread.
// These functions shouldn't return NULL unless otherwise noted.
// These functions shouldn't return nullptr unless otherwise noted.
class BrowserProcessImpl : public BrowserProcess {
public:
BrowserProcessImpl();

View file

@ -100,8 +100,8 @@ std::wstring GetAppInfoHelperForProtocol(ASSOCSTR assoc_str, const GURL& url) {
wchar_t out_buffer[1024];
DWORD buffer_size = std::size(out_buffer);
HRESULT hr =
AssocQueryString(ASSOCF_IS_PROTOCOL, assoc_str, url_scheme.c_str(), NULL,
out_buffer, &buffer_size);
AssocQueryString(ASSOCF_IS_PROTOCOL, assoc_str, url_scheme.c_str(),
nullptr, out_buffer, &buffer_size);
if (FAILED(hr)) {
DLOG(WARNING) << "AssocQueryString failed!";
return std::wstring();
@ -315,7 +315,7 @@ void GetApplicationInfoForProtocolUsingAssocQuery(
void Browser::AddRecentDocument(const base::FilePath& path) {
CComPtr<IShellItem> item;
HRESULT hr = SHCreateItemFromParsingName(path.value().c_str(), NULL,
HRESULT hr = SHCreateItemFromParsingName(path.value().c_str(), nullptr,
IID_PPV_ARGS(&item));
if (SUCCEEDED(hr)) {
SHARDAPPIDINFO info;

View file

@ -62,7 +62,7 @@ class ElectronExtensionMessageFilter : public content::BrowserMessageFilter {
// The BrowserContext associated with our renderer process. This should only
// be accessed on the UI thread! Furthermore since this class is refcounted it
// may outlive |browser_context_|, so make sure to NULL check if in doubt;
// may outlive |browser_context_|, so make sure to nullptr check if in doubt;
// async calls and the like.
raw_ptr<content::BrowserContext> browser_context_;
};

View file

@ -95,7 +95,8 @@ void ElectronExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
std::unique_ptr<base::Value::Dict> ParseManifest(
base::StringPiece manifest_contents) {
JSONStringValueDeserializer deserializer(manifest_contents);
std::unique_ptr<base::Value> manifest = deserializer.Deserialize(NULL, NULL);
std::unique_ptr<base::Value> manifest =
deserializer.Deserialize(nullptr, nullptr);
if (!manifest.get() || !manifest->is_dict()) {
LOG(ERROR) << "Failed to parse extension manifest.";

View file

@ -460,7 +460,7 @@ void FileSelectHelper::RunFileChooserOnUIThread(
? 1
: 0, // 1-based index of default extension to show.
base::FilePath::StringType(),
web_contents->owner_window()->GetNativeWindow(), NULL);
web_contents->owner_window()->GetNativeWindow(), nullptr);
select_file_types_.reset();
}

View file

@ -133,8 +133,8 @@ void FileSelectHelper::ProcessSelectedFilesMacOnUIThread(
temporary_files.end());
// Typically, |temporary_files| are deleted after |web_contents_| is
// destroyed. If |web_contents_| is already NULL, then the temporary files
// need to be deleted now.
// destroyed. If |web_contents_| is already nullptr, then the temporary
// files need to be deleted now.
if (!web_contents_) {
DeleteTemporaryFiles();
RunFileChooserEnd();

View file

@ -1163,7 +1163,7 @@ void NativeWindowViews::SetBackgroundColor(SkColor background_color) {
reinterpret_cast<LONG_PTR>(brush));
if (previous_brush)
DeleteObject((HBRUSH)previous_brush);
InvalidateRect(GetAcceleratedWidget(), NULL, 1);
InvalidateRect(GetAcceleratedWidget(), nullptr, 1);
#endif
}
@ -1394,7 +1394,7 @@ void NativeWindowViews::SetParentWindow(NativeWindow* parent) {
// For do this we must NOT use the ::SetParent function, instead we must use
// the ::GetWindowLongPtr or ::SetWindowLongPtr functions with "nIndex" set
// to "GWLP_HWNDPARENT" which actually means the window owner.
HWND hwndParent = parent ? parent->GetAcceleratedWidget() : NULL;
HWND hwndParent = parent ? parent->GetAcceleratedWidget() : nullptr;
if (hwndParent ==
(HWND)::GetWindowLongPtr(GetAcceleratedWidget(), GWLP_HWNDPARENT))
return;

View file

@ -297,7 +297,7 @@ class NativeWindowViews : public NativeWindow,
static std::set<NativeWindowViews*> forwarding_windows_;
static HHOOK mouse_hook_;
bool forwarding_mouse_messages_ = false;
HWND legacy_window_ = NULL;
HWND legacy_window_ = nullptr;
bool layered_ = false;
// Set to true if the window is always on top and behind the task bar.

View file

@ -206,7 +206,7 @@ bool IsScreenReaderActive() {
} // namespace
std::set<NativeWindowViews*> NativeWindowViews::forwarding_windows_;
HHOOK NativeWindowViews::mouse_hook_ = NULL;
HHOOK NativeWindowViews::mouse_hook_ = nullptr;
void NativeWindowViews::Maximize() {
// Only use Maximize() when window is NOT transparent style
@ -509,7 +509,7 @@ void NativeWindowViews::SetForwardMouseMessages(bool forward) {
reinterpret_cast<DWORD_PTR>(this));
if (!mouse_hook_) {
mouse_hook_ = SetWindowsHookEx(WH_MOUSE_LL, MouseHookProc, NULL, 0);
mouse_hook_ = SetWindowsHookEx(WH_MOUSE_LL, MouseHookProc, nullptr, 0);
}
} else if (!forward && forwarding_mouse_messages_) {
forwarding_mouse_messages_ = false;
@ -519,7 +519,7 @@ void NativeWindowViews::SetForwardMouseMessages(bool forward) {
if (forwarding_windows_.empty()) {
UnhookWindowsHookEx(mouse_hook_);
mouse_hook_ = NULL;
mouse_hook_ = nullptr;
}
}
}
@ -557,7 +557,7 @@ LRESULT CALLBACK NativeWindowViews::MouseHookProc(int n_code,
WPARAM w_param,
LPARAM l_param) {
if (n_code < 0) {
return CallNextHookEx(NULL, n_code, w_param, l_param);
return CallNextHookEx(nullptr, n_code, w_param, l_param);
}
// Post a WM_MOUSEMOVE message for those windows whose client area contains
@ -581,7 +581,7 @@ LRESULT CALLBACK NativeWindowViews::MouseHookProc(int n_code,
}
}
return CallNextHookEx(NULL, n_code, w_param, l_param);
return CallNextHookEx(nullptr, n_code, w_param, l_param);
}
} // namespace electron

View file

@ -122,7 +122,7 @@ void LibnotifyNotification::Show(const NotificationOptions& options) {
if (!options.tag.empty()) {
GQuark id = g_quark_from_string(options.tag.c_str());
g_object_set(G_OBJECT(notification_), "id", id, NULL);
g_object_set(G_OBJECT(notification_), "id", id, nullptr);
}
// Always try to append notifications.

View file

@ -117,8 +117,8 @@ bool RelaunchAppWithHelper(const base::FilePath& helper,
#if BUILDFLAG(IS_WIN)
// Synchronize with the relauncher process.
StringType name = internal::GetWaitEventName(process.Pid());
HANDLE wait_event = ::CreateEventW(NULL, TRUE, FALSE, name.c_str());
if (wait_event != NULL) {
HANDLE wait_event = ::CreateEventW(nullptr, TRUE, FALSE, name.c_str());
if (wait_event != nullptr) {
WaitForSingleObject(wait_event, 1000);
CloseHandle(wait_event);
}

View file

@ -40,7 +40,7 @@ void RelauncherSynchronizeWithParent() {
}
struct kevent change = {0};
EV_SET(&change, parent_pid, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, NULL);
EV_SET(&change, parent_pid, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, nullptr);
if (kevent(kq.get(), &change, 1, nullptr, 0, nullptr) == -1) {
PLOG(ERROR) << "kevent (add)";
return;

View file

@ -47,16 +47,16 @@ HANDLE GetParentProcessHandle(base::ProcessHandle handle) {
ResolveNTFunctionPtr("NtQueryInformationProcess", &NtQueryInformationProcess);
if (!NtQueryInformationProcess) {
LOG(ERROR) << "Unable to get NtQueryInformationProcess";
return NULL;
return nullptr;
}
PROCESS_BASIC_INFORMATION pbi;
LONG status =
NtQueryInformationProcess(handle, ProcessBasicInformation, &pbi,
sizeof(PROCESS_BASIC_INFORMATION), NULL);
sizeof(PROCESS_BASIC_INFORMATION), nullptr);
if (!NT_SUCCESS(status)) {
LOG(ERROR) << "NtQueryInformationProcess failed";
return NULL;
return nullptr;
}
return ::OpenProcess(PROCESS_ALL_ACCESS, TRUE,
@ -131,7 +131,7 @@ void RelauncherSynchronizeWithParent() {
// Notify the parent process that it can quit now.
StringType name = internal::GetWaitEventName(process.Pid());
base::win::ScopedHandle wait_event(
CreateEvent(NULL, TRUE, FALSE, name.c_str()));
CreateEvent(nullptr, TRUE, FALSE, name.c_str()));
::SetEvent(wait_event.Get());
// Wait for parent process to quit.

View file

@ -21,14 +21,14 @@ namespace certificate_trust {
BOOL AddToTrustedRootStore(const PCCERT_CONTEXT cert_context,
const scoped_refptr<net::X509Certificate>& cert) {
auto* root_cert_store = CertOpenStore(
CERT_STORE_PROV_SYSTEM, 0, NULL, CERT_SYSTEM_STORE_CURRENT_USER, L"Root");
CERT_STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM_STORE_CURRENT_USER, L"Root");
if (root_cert_store == NULL) {
if (root_cert_store == nullptr) {
return false;
}
auto result = CertAddCertificateContextToStore(
root_cert_store, cert_context, CERT_STORE_ADD_REPLACE_EXISTING, NULL);
root_cert_store, cert_context, CERT_STORE_ADD_REPLACE_EXISTING, nullptr);
if (result) {
// force Chromium to reload it's database for this certificate
@ -44,7 +44,7 @@ BOOL AddToTrustedRootStore(const PCCERT_CONTEXT cert_context,
CERT_CHAIN_PARA GetCertificateChainParameters() {
CERT_ENHKEY_USAGE enhkey_usage;
enhkey_usage.cUsageIdentifier = 0;
enhkey_usage.rgpszUsageIdentifier = NULL;
enhkey_usage.rgpszUsageIdentifier = nullptr;
CERT_USAGE_MATCH cert_usage;
// ensure the rules are applied to the entire chain
@ -69,8 +69,8 @@ v8::Local<v8::Promise> ShowCertificateTrust(
auto cert_context = net::x509_util::CreateCertContextWithChain(cert.get());
auto params = GetCertificateChainParameters();
if (CertGetCertificateChain(NULL, cert_context.get(), NULL, NULL, &params,
NULL, NULL, &chain_context)) {
if (CertGetCertificateChain(nullptr, cert_context.get(), nullptr, nullptr,
&params, 0, nullptr, &chain_context)) {
auto error_status = chain_context->TrustStatus.dwErrorStatus;
if (error_status == CERT_TRUST_IS_SELF_SIGNED ||
error_status == CERT_TRUST_IS_UNTRUSTED_ROOT) {

View file

@ -63,8 +63,8 @@ NSString* ContainingDiskImageDevice(NSString* bundlePath) {
NSDictionary* info =
[NSPropertyListSerialization propertyListWithData:data
options:NSPropertyListImmutable
format:NULL
error:NULL];
format:nil
error:nil];
if (![info isKindOfClass:[NSDictionary class]])
return nil;
@ -100,7 +100,7 @@ NSString* ContainingDiskImageDevice(NSString* bundlePath) {
NSString* ResolvePath(NSString* path) {
NSString* standardizedPath = [path stringByStandardizingPath];
char resolved[PATH_MAX];
if (realpath([standardizedPath UTF8String], resolved) == NULL)
if (realpath([standardizedPath UTF8String], resolved) == nullptr)
return path;
return @(resolved);
}
@ -147,20 +147,20 @@ bool AuthorizedInstall(NSString* srcPath, NSString* dstPath, bool* canceled) {
// Get the authorization
OSStatus err =
AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment,
AuthorizationCreate(nullptr, kAuthorizationEmptyEnvironment,
kAuthorizationFlagDefaults, &myAuthorizationRef);
if (err != errAuthorizationSuccess)
return false;
AuthorizationItem myItems = {kAuthorizationRightExecute, 0, NULL, 0};
AuthorizationItem myItems = {kAuthorizationRightExecute, 0, nullptr, 0};
AuthorizationRights myRights = {1, &myItems};
AuthorizationFlags myFlags =
(AuthorizationFlags)(kAuthorizationFlagInteractionAllowed |
kAuthorizationFlagExtendRights |
kAuthorizationFlagPreAuthorize);
err = AuthorizationCopyRights(myAuthorizationRef, &myRights, NULL, myFlags,
NULL);
err = AuthorizationCopyRights(myAuthorizationRef, &myRights, nullptr, myFlags,
nullptr);
if (err != errAuthorizationSuccess) {
if (err == errAuthorizationCanceled && canceled)
*canceled = true;
@ -170,7 +170,7 @@ bool AuthorizedInstall(NSString* srcPath, NSString* dstPath, bool* canceled) {
static OSStatus (*security_AuthorizationExecuteWithPrivileges)(
AuthorizationRef authorization, const char* pathToTool,
AuthorizationFlags options, char* const* arguments,
FILE** communicationsPipe) = NULL;
FILE** communicationsPipe) = nullptr;
if (!security_AuthorizationExecuteWithPrivileges) {
// On 10.7, AuthorizationExecuteWithPrivileges is deprecated. We want to
// still use it since there's no good alternative (without requiring code
@ -188,9 +188,10 @@ bool AuthorizedInstall(NSString* srcPath, NSString* dstPath, bool* canceled) {
// Delete the destination
{
char rf[] = "-rf";
char* args[] = {rf, (char*)[dstPath fileSystemRepresentation], NULL};
char* args[] = {rf, (char*)[dstPath fileSystemRepresentation], nullptr};
err = security_AuthorizationExecuteWithPrivileges(
myAuthorizationRef, "/bin/rm", kAuthorizationFlagDefaults, args, NULL);
myAuthorizationRef, "/bin/rm", kAuthorizationFlagDefaults, args,
nullptr);
if (err != errAuthorizationSuccess)
goto fail;
@ -205,9 +206,10 @@ bool AuthorizedInstall(NSString* srcPath, NSString* dstPath, bool* canceled) {
{
char pR[] = "-pR";
char* args[] = {pR, (char*)[srcPath fileSystemRepresentation],
(char*)[dstPath fileSystemRepresentation], NULL};
(char*)[dstPath fileSystemRepresentation], nullptr};
err = security_AuthorizationExecuteWithPrivileges(
myAuthorizationRef, "/bin/cp", kAuthorizationFlagDefaults, args, NULL);
myAuthorizationRef, "/bin/cp", kAuthorizationFlagDefaults, args,
nullptr);
if (err != errAuthorizationSuccess)
goto fail;
@ -272,8 +274,8 @@ bool Trash(NSString* path) {
if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_8) {
result = [[NSFileManager defaultManager]
trashItemAtURL:[NSURL fileURLWithPath:path]
resultingItemURL:NULL
error:NULL];
resultingItemURL:nil
error:nil];
}
// As a last resort try trashing with AppleScript.

View file

@ -90,7 +90,7 @@ NSMenu* MakeEmptySubmenu() {
NSString* empty_menu_title =
l10n_util::GetNSString(IDS_APP_MENU_EMPTY_SUBMENU);
[submenu addItemWithTitle:empty_menu_title action:NULL keyEquivalent:@""];
[submenu addItemWithTitle:empty_menu_title action:nullptr keyEquivalent:@""];
[[submenu itemAtIndex:0] setEnabled:NO];
return submenu;
}

View file

@ -63,7 +63,7 @@ class FileChooserDialog {
if (electron::IsElectron_gtkInitialized()) {
dialog_ = GTK_FILE_CHOOSER(gtk_file_chooser_native_new(
settings.title.c_str(), NULL, action,
settings.title.c_str(), nullptr, action,
label.empty() ? nullptr : label.c_str(), nullptr));
} else {
const char* confirm_text = gtk_util::GetOkLabel();
@ -75,8 +75,8 @@ class FileChooserDialog {
confirm_text = gtk_util::GetOpenLabel();
dialog_ = GTK_FILE_CHOOSER(gtk_file_chooser_dialog_new(
settings.title.c_str(), NULL, action, gtk_util::GetCancelLabel(),
GTK_RESPONSE_CANCEL, confirm_text, GTK_RESPONSE_ACCEPT, NULL));
settings.title.c_str(), nullptr, action, gtk_util::GetCancelLabel(),
GTK_RESPONSE_CANCEL, confirm_text, GTK_RESPONSE_ACCEPT, nullptr));
}
if (parent_) {

View file

@ -68,9 +68,9 @@ static HRESULT GetFileNameFromShellItem(IShellItem* pShellItem,
SIGDN type,
LPWSTR lpstr,
size_t cchLength) {
assert(pShellItem != NULL);
assert(pShellItem != nullptr);
LPWSTR lpstrName = NULL;
LPWSTR lpstrName = nullptr;
HRESULT hRet = pShellItem->GetDisplayName(type, &lpstrName);
if (SUCCEEDED(hRet)) {
@ -93,7 +93,7 @@ static void SetDefaultFolder(IFileDialog* dialog,
IsDirectory(file_path) ? file_path.value() : file_path.DirName().value();
ATL::CComPtr<IShellItem> folder_item;
HRESULT hr = SHCreateItemFromParsingName(directory.c_str(), NULL,
HRESULT hr = SHCreateItemFromParsingName(directory.c_str(), nullptr,
IID_PPV_ARGS(&folder_item));
if (SUCCEEDED(hr))
dialog->SetFolder(folder_item);
@ -105,7 +105,7 @@ static HRESULT ShowFileDialog(IFileDialog* dialog,
settings.parent_window
? static_cast<electron::NativeWindowViews*>(settings.parent_window)
->GetAcceleratedWidget()
: NULL;
: nullptr;
return dialog->Show(parent_window);
}

View file

@ -156,7 +156,7 @@ DialogResult ShowTaskDialogWstr(gfx::AcceleratedWidget parent,
TASKDIALOGCONFIG config = {0};
config.cbSize = sizeof(config);
config.hInstance = GetModuleHandle(NULL);
config.hInstance = GetModuleHandle(nullptr);
config.dwFlags = flags;
if (parent) {

View file

@ -15,14 +15,14 @@
namespace {
bool MonitorHasAutohideTaskbarForEdge(UINT edge, HMONITOR monitor) {
APPBARDATA taskbar_data = {sizeof(APPBARDATA), NULL, 0, edge};
APPBARDATA taskbar_data = {sizeof(APPBARDATA), nullptr, 0, edge};
taskbar_data.hWnd = ::GetForegroundWindow();
// MSDN documents an ABM_GETAUTOHIDEBAREX, which supposedly takes a monitor
// rect and returns autohide bars on that monitor. This sounds like a good
// idea for multi-monitor systems. Unfortunately, it appears to not work at
// least some of the time (erroneously returning NULL) and there's almost no
// online documentation or other sample code using it that suggests ways to
// least some of the time (erroneously returning nullptr) and there's almost
// no online documentation or other sample code using it that suggests ways to
// address this problem. We do the following:-
// 1. Use the ABM_GETAUTOHIDEBAR message. If it works, i.e. returns a valid
// window we are done.
@ -40,7 +40,7 @@ bool MonitorHasAutohideTaskbarForEdge(UINT edge, HMONITOR monitor) {
if (!(taskbar_state & ABS_AUTOHIDE))
return false;
new_taskbar_data.hWnd = ::FindWindow(L"Shell_TrayWnd", NULL);
new_taskbar_data.hWnd = ::FindWindow(L"Shell_TrayWnd", nullptr);
if (!::IsWindow(new_taskbar_data.hWnd))
return false;
@ -103,7 +103,7 @@ namespace electron {
HICON ViewsDelegate::GetDefaultWindowIcon() const {
// Use current exe's icon as default window icon.
return LoadIcon(GetModuleHandle(NULL),
return LoadIcon(GetModuleHandle(nullptr),
MAKEINTRESOURCE(1 /* IDR_MAINFRAME */));
}

View file

@ -65,7 +65,7 @@ bool AppendFile(const JumpListItem& item, IObjectCollection* collection) {
DCHECK(collection);
CComPtr<IShellItem> file;
if (SUCCEEDED(SHCreateItemFromParsingName(item.path.value().c_str(), NULL,
if (SUCCEEDED(SHCreateItemFromParsingName(item.path.value().c_str(), nullptr,
IID_PPV_ARGS(&file))))
return SUCCEEDED(collection->AddObject(file));

View file

@ -57,7 +57,7 @@ NotifyIconHost::NotifyIconHost() {
base::win::InitializeWindowClass(
kNotifyIconHostWindowClass,
&base::win::WrappedWindowProc<NotifyIconHost::WndProcStatic>, 0, 0, 0,
NULL, NULL, NULL, NULL, NULL, &window_class);
nullptr, nullptr, nullptr, nullptr, nullptr, &window_class);
instance_ = window_class.hInstance;
atom_ = RegisterClassEx(&window_class);
CHECK(atom_);
@ -144,7 +144,7 @@ LRESULT CALLBACK NotifyIconHost::WndProc(HWND hwnd,
}
return TRUE;
} else if (message == kNotifyIconMessage) {
NotifyIcon* win_icon = NULL;
NotifyIcon* win_icon = nullptr;
// Find the selected status icon.
for (NotifyIcons::const_iterator i(notify_icons_.begin());

View file

@ -182,7 +182,7 @@ bool TaskbarHost::SetThumbnailClip(HWND window, const gfx::Rect& region) {
return false;
if (region.IsEmpty()) {
return SUCCEEDED(taskbar_->SetThumbnailClip(window, NULL));
return SUCCEEDED(taskbar_->SetThumbnailClip(window, nullptr));
} else {
RECT rect =
display::win::ScreenWin::DIPToScreenRect(window, region).ToRECT();

View file

@ -114,8 +114,8 @@ base::win::ScopedHICON ReadICOFromPath(int size, const base::FilePath& path) {
// Load the icon from file.
return base::win::ScopedHICON(
static_cast<HICON>(LoadImage(NULL, image_path.value().c_str(), IMAGE_ICON,
size, size, LR_LOADFROMFILE)));
static_cast<HICON>(LoadImage(nullptr, image_path.value().c_str(),
IMAGE_ICON, size, size, LR_LOADFROMFILE)));
}
#endif
@ -214,7 +214,7 @@ HICON NativeImage::GetHICON(int size) {
// Then convert the image to ICO.
if (image_.IsEmpty())
return NULL;
return nullptr;
auto& hicon = hicons_[size];
hicon = IconUtil::CreateHICONFromSkBitmap(image_.AsBitmap());

View file

@ -62,7 +62,7 @@ v8::Local<v8::Promise> NativeImage::CreateThumbnailFromPath(
hr = pThumbnailCache->GetThumbnail(
pItem.Get(), size.width(),
WTS_FLAGS::WTS_SCALETOREQUESTEDSIZE | WTS_FLAGS::WTS_SCALEUP, &pThumbnail,
NULL, NULL);
nullptr, nullptr);
if (FAILED(hr)) {
promise.RejectWithErrorMessage(
@ -71,7 +71,7 @@ v8::Local<v8::Promise> NativeImage::CreateThumbnailFromPath(
}
// Init HBITMAP
HBITMAP hBitmap = NULL;
HBITMAP hBitmap = nullptr;
hr = pThumbnail->GetSharedBitmap(&hBitmap);
if (FAILED(hr)) {
promise.RejectWithErrorMessage("Failed to extract bitmap from thumbnail");

View file

@ -15,9 +15,9 @@ struct Converter<electron::NativeWindow*> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
electron::NativeWindow** out) {
// null would be transferred to NULL.
// null would be transferred to nullptr.
if (val->IsNull()) {
*out = NULL;
*out = nullptr;
return true;
}

View file

@ -25,7 +25,8 @@ NodeBindingsWin::NodeBindingsWin(BrowserEnvironment browser_env)
if (event_loop->iocp && event_loop->iocp != INVALID_HANDLE_VALUE)
CloseHandle(event_loop->iocp);
event_loop->iocp = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 2);
event_loop->iocp =
CreateIoCompletionPort(INVALID_HANDLE_VALUE, nullptr, 0, 2);
}
}
@ -44,7 +45,7 @@ void NodeBindingsWin::PollEvents() {
timeout);
// Give the event back so libuv can deal with it.
if (overlapped != NULL)
if (overlapped != nullptr)
PostQueuedCompletionStatus(event_loop->iocp, bytes, key, overlapped);
}

View file

@ -34,9 +34,9 @@ std::string OpenURL(NSURL* ns_url, bool activate) {
CFURLRef ref =
LSCopyDefaultApplicationURLForURL(cf_url, kLSRolesAll, nullptr);
// If no application could be found, NULL is returned and outError
// (if not NULL) is populated with kLSApplicationNotFoundErr.
if (ref == NULL)
// If no application could be found, nullptr is returned and outError
// (if not nullptr) is populated with kLSApplicationNotFoundErr.
if (ref == nullptr)
return "No application in the Launch Services database matches the input "
"criteria.";
@ -72,7 +72,7 @@ std::string OpenPathOnThread(const base::FilePath& full_path) {
withAppBundleIdentifier:nil
options:launch_options
additionalEventParamDescriptor:nil
launchIdentifiers:NULL];
launchIdentifiers:nil];
return success ? "" : "Failed to open path";
}

View file

@ -117,7 +117,7 @@ HRESULT DeleteFileProgressSink::PreDeleteItem(DWORD dwFlags, IShellItem*) {
}
HRESULT DeleteFileProgressSink::QueryInterface(REFIID riid, LPVOID* ppvObj) {
// Always set out parameter to NULL, validating it first.
// Always set out parameter to nullptr, validating it first.
if (!ppvObj)
return E_INVALIDARG;
*ppvObj = nullptr;
@ -285,16 +285,16 @@ void ShowItemInFolderOnWorkerThread(const base::FilePath& full_path) {
return;
base::win::ScopedCoMem<ITEMIDLIST> dir_item;
hr = desktop->ParseDisplayName(NULL, NULL,
hr = desktop->ParseDisplayName(nullptr, nullptr,
const_cast<wchar_t*>(dir.value().c_str()),
NULL, &dir_item, NULL);
nullptr, &dir_item, nullptr);
if (FAILED(hr))
return;
base::win::ScopedCoMem<ITEMIDLIST> file_item;
hr = desktop->ParseDisplayName(
NULL, NULL, const_cast<wchar_t*>(full_path.value().c_str()), NULL,
&file_item, NULL);
nullptr, nullptr, const_cast<wchar_t*>(full_path.value().c_str()),
nullptr, &file_item, nullptr);
if (FAILED(hr))
return;
@ -305,7 +305,8 @@ void ShowItemInFolderOnWorkerThread(const base::FilePath& full_path) {
// found" even though the file is there. In these cases, ShellExecute()
// seems to work as a fallback (although it won't select the file).
if (hr == ERROR_FILE_NOT_FOUND) {
ShellExecute(NULL, L"open", dir.value().c_str(), NULL, NULL, SW_SHOW);
ShellExecute(nullptr, L"open", dir.value().c_str(), nullptr, nullptr,
SW_SHOW);
} else {
LOG(WARNING) << " " << __func__ << "(): Can't open full_path = \""
<< full_path.value() << "\""
@ -380,7 +381,7 @@ bool MoveItemToTrashWithError(const base::FilePath& path,
// Create an IShellItem from the supplied source path.
Microsoft::WRL::ComPtr<IShellItem> delete_item;
if (FAILED(SHCreateItemFromParsingName(path.value().c_str(), NULL,
if (FAILED(SHCreateItemFromParsingName(path.value().c_str(), nullptr,
IID_PPV_ARGS(&delete_item)))) {
*error = "Failed to parse path";
return false;
@ -433,8 +434,8 @@ bool GetFolderPath(int key, base::FilePath* result) {
switch (key) {
case electron::DIR_RECENT:
if (FAILED(SHGetFolderPath(NULL, CSIDL_RECENT, NULL, SHGFP_TYPE_CURRENT,
system_buffer))) {
if (FAILED(SHGetFolderPath(nullptr, CSIDL_RECENT, nullptr,
SHGFP_TYPE_CURRENT, system_buffer))) {
return false;
}
*result = base::FilePath(system_buffer);