refactor: replace remaining NULL
with nullptr
(#40053)
refactor: use nullptr everywhere
This commit is contained in:
parent
9d0e6d09f0
commit
04b2ba84cd
34 changed files with 98 additions and 93 deletions
|
@ -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, ¶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) {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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_) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 */));
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue