diff --git a/shell/app/electron_main_mac.cc b/shell/app/electron_main_mac.cc index 531cdbd2117..902aea2fa7c 100644 --- a/shell/app/electron_main_mac.cc +++ b/shell/app/electron_main_mac.cc @@ -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."); } diff --git a/shell/browser/api/electron_api_app_mac.mm b/shell/browser/api/electron_api_app_mac.mm index 9b244c8f1b9..90ca396fe80 100644 --- a/shell/browser/api/electron_api_app_mac.mm +++ b/shell/browser/api/electron_api_app_mac.mm @@ -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; } diff --git a/shell/browser/api/electron_api_menu.h b/shell/browser/api/electron_api_menu.h index 3cb0681efd7..697fbd950fc 100644 --- a/shell/browser/api/electron_api_menu.h +++ b/shell/browser/api/electron_api_menu.h @@ -132,7 +132,7 @@ struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Local val, electron::ElectronMenuModel** out) { - // null would be transferred to NULL. + // null would be transferred to nullptr. if (val->IsNull()) { *out = nullptr; return true; diff --git a/shell/browser/api/electron_api_power_monitor_win.cc b/shell/browser/api/electron_api_power_monitor_win.cc index 0e400dc44e6..a7f1acfdf07 100644 --- a/shell/browser/api/electron_api_power_monitor_win.cc +++ b/shell/browser/api/electron_api_power_monitor_win.cc @@ -27,8 +27,8 @@ void PowerMonitor::InitPlatformSpecificMonitors() { WNDCLASSEX window_class; base::win::InitializeWindowClass( kPowerMonitorWindowClass, - &base::win::WrappedWindowProc, 0, 0, 0, NULL, - NULL, NULL, NULL, NULL, &window_class); + &base::win::WrappedWindowProc, 0, 0, 0, + nullptr, nullptr, nullptr, nullptr, nullptr, &window_class); instance_ = window_class.hInstance; atom_ = RegisterClassEx(&window_class); diff --git a/shell/browser/api/electron_api_system_preferences_win.cc b/shell/browser/api/electron_api_system_preferences_win.cc index 1e05b697d1b..e387f1dc2c8 100644 --- a/shell/browser/api/electron_api_system_preferences_win.cc +++ b/shell/browser/api/electron_api_system_preferences_win.cc @@ -171,7 +171,7 @@ void SystemPreferences::InitializeWindow() { base::win::InitializeWindowClass( kSystemPreferencesWindowClass, &base::win::WrappedWindowProc, 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); diff --git a/shell/browser/browser_process_impl.h b/shell/browser/browser_process_impl.h index f54a1ab4ff6..567c05c3c60 100644 --- a/shell/browser/browser_process_impl.h +++ b/shell/browser/browser_process_impl.h @@ -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(); diff --git a/shell/browser/browser_win.cc b/shell/browser/browser_win.cc index af93340d208..8595a5e575c 100644 --- a/shell/browser/browser_win.cc +++ b/shell/browser/browser_win.cc @@ -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 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; diff --git a/shell/browser/extensions/electron_extension_message_filter.h b/shell/browser/extensions/electron_extension_message_filter.h index 103c85d2e56..eb7a2f526e8 100644 --- a/shell/browser/extensions/electron_extension_message_filter.h +++ b/shell/browser/extensions/electron_extension_message_filter.h @@ -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 browser_context_; }; diff --git a/shell/browser/extensions/electron_extension_system.cc b/shell/browser/extensions/electron_extension_system.cc index 6c8669b3cfb..80d1bc0dfab 100644 --- a/shell/browser/extensions/electron_extension_system.cc +++ b/shell/browser/extensions/electron_extension_system.cc @@ -95,7 +95,8 @@ void ElectronExtensionSystem::InitForRegularProfile(bool extensions_enabled) { std::unique_ptr ParseManifest( base::StringPiece manifest_contents) { JSONStringValueDeserializer deserializer(manifest_contents); - std::unique_ptr manifest = deserializer.Deserialize(NULL, NULL); + std::unique_ptr manifest = + deserializer.Deserialize(nullptr, nullptr); if (!manifest.get() || !manifest->is_dict()) { LOG(ERROR) << "Failed to parse extension manifest."; diff --git a/shell/browser/file_select_helper.cc b/shell/browser/file_select_helper.cc index 8cc72bf0566..dc6ea804e07 100644 --- a/shell/browser/file_select_helper.cc +++ b/shell/browser/file_select_helper.cc @@ -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(); } diff --git a/shell/browser/file_select_helper_mac.mm b/shell/browser/file_select_helper_mac.mm index 528eeda65a5..2fd2d99b9f2 100644 --- a/shell/browser/file_select_helper_mac.mm +++ b/shell/browser/file_select_helper_mac.mm @@ -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(); diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc index 2cf0682a896..d67f31388c4 100644 --- a/shell/browser/native_window_views.cc +++ b/shell/browser/native_window_views.cc @@ -1163,7 +1163,7 @@ void NativeWindowViews::SetBackgroundColor(SkColor background_color) { reinterpret_cast(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; diff --git a/shell/browser/native_window_views.h b/shell/browser/native_window_views.h index e7d4c30b2ae..7be1cf3f4f7 100644 --- a/shell/browser/native_window_views.h +++ b/shell/browser/native_window_views.h @@ -297,7 +297,7 @@ class NativeWindowViews : public NativeWindow, static std::set 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. diff --git a/shell/browser/native_window_views_win.cc b/shell/browser/native_window_views_win.cc index e5ea8d7a2a2..98991239099 100644 --- a/shell/browser/native_window_views_win.cc +++ b/shell/browser/native_window_views_win.cc @@ -206,7 +206,7 @@ bool IsScreenReaderActive() { } // namespace std::set 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(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 diff --git a/shell/browser/notifications/linux/libnotify_notification.cc b/shell/browser/notifications/linux/libnotify_notification.cc index 3f7a2fa24f8..82f7178078e 100644 --- a/shell/browser/notifications/linux/libnotify_notification.cc +++ b/shell/browser/notifications/linux/libnotify_notification.cc @@ -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. diff --git a/shell/browser/relauncher.cc b/shell/browser/relauncher.cc index 43921a64efb..ed22f0d1700 100644 --- a/shell/browser/relauncher.cc +++ b/shell/browser/relauncher.cc @@ -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); } diff --git a/shell/browser/relauncher_mac.cc b/shell/browser/relauncher_mac.cc index 5a8954e74a6..17b93e71daa 100644 --- a/shell/browser/relauncher_mac.cc +++ b/shell/browser/relauncher_mac.cc @@ -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; diff --git a/shell/browser/relauncher_win.cc b/shell/browser/relauncher_win.cc index 39112f41eb2..2e7b0150ad0 100644 --- a/shell/browser/relauncher_win.cc +++ b/shell/browser/relauncher_win.cc @@ -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. diff --git a/shell/browser/ui/certificate_trust_win.cc b/shell/browser/ui/certificate_trust_win.cc index 742377c3111..4536fbcf8f5 100644 --- a/shell/browser/ui/certificate_trust_win.cc +++ b/shell/browser/ui/certificate_trust_win.cc @@ -21,14 +21,14 @@ namespace certificate_trust { BOOL AddToTrustedRootStore(const PCCERT_CONTEXT cert_context, const scoped_refptr& 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 ShowCertificateTrust( auto cert_context = net::x509_util::CreateCertContextWithChain(cert.get()); auto params = GetCertificateChainParameters(); - if (CertGetCertificateChain(NULL, cert_context.get(), NULL, NULL, ¶ms, - NULL, NULL, &chain_context)) { + if (CertGetCertificateChain(nullptr, cert_context.get(), nullptr, nullptr, + ¶ms, 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) { diff --git a/shell/browser/ui/cocoa/electron_bundle_mover.mm b/shell/browser/ui/cocoa/electron_bundle_mover.mm index f6a7c12ab5a..b1a9e17d5a3 100644 --- a/shell/browser/ui/cocoa/electron_bundle_mover.mm +++ b/shell/browser/ui/cocoa/electron_bundle_mover.mm @@ -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. diff --git a/shell/browser/ui/cocoa/electron_menu_controller.mm b/shell/browser/ui/cocoa/electron_menu_controller.mm index ea260fcab5e..ef4f17ab25b 100644 --- a/shell/browser/ui/cocoa/electron_menu_controller.mm +++ b/shell/browser/ui/cocoa/electron_menu_controller.mm @@ -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; } diff --git a/shell/browser/ui/file_dialog_gtk.cc b/shell/browser/ui/file_dialog_gtk.cc index b6d9f9bb14a..f76194721cd 100644 --- a/shell/browser/ui/file_dialog_gtk.cc +++ b/shell/browser/ui/file_dialog_gtk.cc @@ -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_) { diff --git a/shell/browser/ui/file_dialog_win.cc b/shell/browser/ui/file_dialog_win.cc index 7000e33fb4c..cefe30f245b 100644 --- a/shell/browser/ui/file_dialog_win.cc +++ b/shell/browser/ui/file_dialog_win.cc @@ -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 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(settings.parent_window) ->GetAcceleratedWidget() - : NULL; + : nullptr; return dialog->Show(parent_window); } diff --git a/shell/browser/ui/message_box_win.cc b/shell/browser/ui/message_box_win.cc index 4c0765e26db..4082a76dc25 100644 --- a/shell/browser/ui/message_box_win.cc +++ b/shell/browser/ui/message_box_win.cc @@ -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) { diff --git a/shell/browser/ui/views/electron_views_delegate_win.cc b/shell/browser/ui/views/electron_views_delegate_win.cc index aa0dac14415..6c8048e70a0 100644 --- a/shell/browser/ui/views/electron_views_delegate_win.cc +++ b/shell/browser/ui/views/electron_views_delegate_win.cc @@ -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 */)); } diff --git a/shell/browser/ui/win/jump_list.cc b/shell/browser/ui/win/jump_list.cc index 6d868e6d9e2..00e8a49e218 100644 --- a/shell/browser/ui/win/jump_list.cc +++ b/shell/browser/ui/win/jump_list.cc @@ -65,7 +65,7 @@ bool AppendFile(const JumpListItem& item, IObjectCollection* collection) { DCHECK(collection); CComPtr 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)); diff --git a/shell/browser/ui/win/notify_icon_host.cc b/shell/browser/ui/win/notify_icon_host.cc index bcd9ce662b0..389ebcc1ef8 100644 --- a/shell/browser/ui/win/notify_icon_host.cc +++ b/shell/browser/ui/win/notify_icon_host.cc @@ -57,7 +57,7 @@ NotifyIconHost::NotifyIconHost() { base::win::InitializeWindowClass( kNotifyIconHostWindowClass, &base::win::WrappedWindowProc, 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()); diff --git a/shell/browser/ui/win/taskbar_host.cc b/shell/browser/ui/win/taskbar_host.cc index b20a4aa969a..e17a11fa7a9 100644 --- a/shell/browser/ui/win/taskbar_host.cc +++ b/shell/browser/ui/win/taskbar_host.cc @@ -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(); diff --git a/shell/common/api/electron_api_native_image.cc b/shell/common/api/electron_api_native_image.cc index d9a4916ee0f..a2994e1e33a 100644 --- a/shell/common/api/electron_api_native_image.cc +++ b/shell/common/api/electron_api_native_image.cc @@ -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(LoadImage(NULL, image_path.value().c_str(), IMAGE_ICON, - size, size, LR_LOADFROMFILE))); + static_cast(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()); diff --git a/shell/common/api/electron_api_native_image_win.cc b/shell/common/api/electron_api_native_image_win.cc index baa92450154..4bc5e8f4b9d 100644 --- a/shell/common/api/electron_api_native_image_win.cc +++ b/shell/common/api/electron_api_native_image_win.cc @@ -62,7 +62,7 @@ v8::Local 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 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"); diff --git a/shell/common/gin_converters/native_window_converter.h b/shell/common/gin_converters/native_window_converter.h index 106ca836cd5..498c4303b79 100644 --- a/shell/common/gin_converters/native_window_converter.h +++ b/shell/common/gin_converters/native_window_converter.h @@ -15,9 +15,9 @@ struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Local 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; } diff --git a/shell/common/node_bindings_win.cc b/shell/common/node_bindings_win.cc index eb484995ebe..e6efce987de 100644 --- a/shell/common/node_bindings_win.cc +++ b/shell/common/node_bindings_win.cc @@ -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); } diff --git a/shell/common/platform_util_mac.mm b/shell/common/platform_util_mac.mm index 585853700c9..a700c04d6dc 100644 --- a/shell/common/platform_util_mac.mm +++ b/shell/common/platform_util_mac.mm @@ -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"; } diff --git a/shell/common/platform_util_win.cc b/shell/common/platform_util_win.cc index d0aca700410..a2deae69bf1 100644 --- a/shell/common/platform_util_win.cc +++ b/shell/common/platform_util_win.cc @@ -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 dir_item; - hr = desktop->ParseDisplayName(NULL, NULL, + hr = desktop->ParseDisplayName(nullptr, nullptr, const_cast(dir.value().c_str()), - NULL, &dir_item, NULL); + nullptr, &dir_item, nullptr); if (FAILED(hr)) return; base::win::ScopedCoMem file_item; hr = desktop->ParseDisplayName( - NULL, NULL, const_cast(full_path.value().c_str()), NULL, - &file_item, NULL); + nullptr, nullptr, const_cast(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 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);