Compare commits

..

16 Commits

Author SHA1 Message Date
David Sanders
5e7689cd30 chore: address code review feedback 2026-04-09 15:35:05 -07:00
David Sanders
7adcfe1027 chore: redundant void argument list [modernize-redundant-void-arg] 2026-04-09 14:52:43 -07:00
David Sanders
496f0946f0 chore: use range-based for loop instead [modernize-loop-convert] 2026-04-09 14:52:43 -07:00
David Sanders
847c5e0613 chore: use '= default' to define a trivial destructor [modernize-use-equals-default] 2026-04-09 14:52:43 -07:00
David Sanders
a36b3b1849 chore: C-style casts are discouraged; use static_cast/const_cast/reinterpret_cast [google-readability-casting] 2026-04-09 14:52:43 -07:00
David Sanders
92a7a12cc8 chore: C-style casts are discouraged; use static_cast [google-readability-casting]
No cast needed here, everything is already the correct type
2026-04-09 13:40:30 -07:00
David Sanders
860840cdeb chore: refactor block to avoid use after move warning from clang-tidy
Looks like clang-tidy couldn't tell these were two mutually exclusive
branches so there was no actual issue, but refactoring is cleaner
anyway since it makes it more DRY.
2026-04-09 13:40:30 -07:00
David Sanders
d0c1465045 chore: warning: C-style casts are discouraged; use static_cast [google-readability-casting]
CFLocaleGetValue already returns CFTypeRef so that redundant static_cast was removed
2026-04-09 13:40:30 -07:00
David Sanders
7d492877ea chore: default arguments on virtual or override methods are prohibited [google-default-arguments] 2026-04-09 13:40:29 -07:00
David Sanders
e17567b307 chore: do not create objects with +new [google-objc-avoid-nsobject-new] 2026-04-09 13:40:29 -07:00
David Sanders
cf9a79962c chore: redundant cast to the same type [google-readability-casting] 2026-04-09 13:40:21 -07:00
David Sanders
b6ac415084 chore: use emplace and use it correctly 2026-04-09 12:51:18 -07:00
Zeenat Lawal
62e637275a fix: move Electron help menu links to default app only (#50629)
* fix: remove Electron links from default help menu

* fix: remove help menu entirely from default menu

* fix: move Electron help menu links to default app

* docs: update default menu items list in menu.md
2026-04-09 12:14:22 -07:00
Shelley Vohr
28c0eb29df fix: webContents.print() ignoring mediaSize when silent (#50808)
fix: webContents.print() ignoring mediaSize when silent

PR #49523 moved the default media size fallback into OnGetDeviceNameToUse,
but the new code unconditionally writes kSettingMediaSize — clobbering
any mediaSize the caller had already set in WebContents::Print() from
options.mediaSize / pageSize. As a result, silent prints with an
explicit pageSize (e.g. "Letter") fell back to A4 with tiny content.

Only populate the default/printer media size when the caller hasn't
already supplied one, preserving the precedence:
  1. user-supplied mediaSize / pageSize
  2. printer default (when usePrinterDefaultPageSize is true)
  3. A4 fallback
2026-04-09 12:16:40 -05:00
Charles Kerr
8a730e2aec fix: remove dangling raw_ptr api::WebContents::zoom_controller_ (#50812)
fix: remove dangling raw_ptr api::WebContents::zoom_controller_
2026-04-09 12:16:17 -05:00
Shelley Vohr
044be7ce40 fix: avoid crash in window.print() when prefilling native print dialog (#50843)
fix: avoid crash in window.print() when prefilling native print dialog

When UpdatePrinterSettings() fails (e.g. the printer rejects the
requested resolution), OnError() nullifies print_info_ via
ReleaseContext(). The return value was not checked, so
AskUserForSettings() passed nil to [NSPrintPanel runModalWithPrintInfo:],
crashing in PJCSessionHasApplicationSetPrinter with a null PMPrintSession.

Check the return value and fall back to UseDefaultSettings() on failure
so the dialog opens with defaults instead of crashing.
2026-04-09 13:14:36 -04:00
21 changed files with 131 additions and 119 deletions

View File

@@ -1,5 +1,5 @@
import { shell } from 'electron/common';
import { app, dialog, BrowserWindow, ipcMain } from 'electron/main';
import { app, dialog, BrowserWindow, ipcMain, Menu } from 'electron/main';
import * as path from 'node:path';
import * as url from 'node:url';
@@ -11,6 +11,60 @@ app.on('window-all-closed', () => {
app.quit();
});
const isMac = process.platform === 'darwin';
app.whenReady().then(() => {
const helpMenu: Electron.MenuItemConstructorOptions = {
role: 'help',
submenu: [
{
label: 'Learn More',
click: async () => {
await shell.openExternal('https://electronjs.org');
}
},
{
label: 'Documentation',
click: async () => {
const version = process.versions.electron;
await shell.openExternal(`https://github.com/electron/electron/tree/v${version}/docs#readme`);
}
},
{
label: 'Community Discussions',
click: async () => {
await shell.openExternal('https://discord.gg/electronjs');
}
},
{
label: 'Search Issues',
click: async () => {
await shell.openExternal('https://github.com/electron/electron/issues');
}
}
]
};
const macAppMenu: Electron.MenuItemConstructorOptions = { role: 'appMenu' };
const template: Electron.MenuItemConstructorOptions[] = [
...(isMac ? [macAppMenu] : []),
{ role: 'fileMenu' },
{ role: 'editMenu' },
{ role: 'viewMenu' },
{ role: 'windowMenu' },
helpMenu
];
Menu.setApplicationMenu(Menu.buildFromTemplate(template));
});
function decorateURL (url: string) {
// safely add `?utm_source=default_app
const parsedUrl = new URL(url);
parsedUrl.searchParams.append('utm_source', 'default_app');
return parsedUrl.toString();
}
// Find the shortest path to the electron binary
const absoluteElectronPath = process.execPath;
const relativeElectronPath = path.relative(process.cwd(), absoluteElectronPath);
@@ -62,7 +116,7 @@ async function createWindow (backgroundColor?: string) {
mainWindow.on('ready-to-show', () => mainWindow!.show());
mainWindow.webContents.setWindowOpenHandler(details => {
shell.openExternal(details.url);
shell.openExternal(decorateURL(details.url));
return { action: 'deny' };
});

View File

@@ -46,7 +46,7 @@ this has the additional effect of removing the menu bar from the window.
> [!NOTE]
> The default menu will be created automatically if the app does not set one.
> It contains standard items such as `File`, `Edit`, `View`, `Window` and `Help`.
> It contains standard items such as `File`, `Edit`, `View`, and `Window`.
#### `Menu.getApplicationMenu()`

View File

@@ -1,5 +1,4 @@
import { shell } from 'electron/common';
import { app, Menu } from 'electron/main';
import { Menu } from 'electron/main';
const isMac = process.platform === 'darwin';
@@ -12,47 +11,13 @@ export const setApplicationMenuWasSet = () => {
export const setDefaultApplicationMenu = () => {
if (applicationMenuWasSet) return;
const helpMenu: Electron.MenuItemConstructorOptions = {
role: 'help',
submenu: app.isPackaged
? []
: [
{
label: 'Learn More',
click: async () => {
await shell.openExternal('https://electronjs.org');
}
},
{
label: 'Documentation',
click: async () => {
const version = process.versions.electron;
await shell.openExternal(`https://github.com/electron/electron/tree/v${version}/docs#readme`);
}
},
{
label: 'Community Discussions',
click: async () => {
await shell.openExternal('https://discord.gg/electronjs');
}
},
{
label: 'Search Issues',
click: async () => {
await shell.openExternal('https://github.com/electron/electron/issues');
}
}
]
};
const macAppMenu: Electron.MenuItemConstructorOptions = { role: 'appMenu' };
const template: Electron.MenuItemConstructorOptions[] = [
...(isMac ? [macAppMenu] : []),
{ role: 'fileMenu' },
{ role: 'editMenu' },
{ role: 'viewMenu' },
{ role: 'windowMenu' },
helpMenu
{ role: 'windowMenu' }
];
const menu = Menu.buildFromTemplate(template);

View File

@@ -620,7 +620,7 @@ index 2a477e820d9f0126a05f86cd44f02c2189275bad..a2e9442ff9f5acf8e301f457b1806251
#if BUILDFLAG(IS_CHROMEOS)
diff --git a/chrome/browser/printing/printer_query_oop.cc b/chrome/browser/printing/printer_query_oop.cc
index dc2a15ab4d784b0b6c85b84a30c3c08a17ed8e3d..e197026e8a7f132c1bf90a0f5f1eabb4f5f064ee 100644
index dc2a15ab4d784b0b6c85b84a30c3c08a17ed8e3d..5ca7920c8525c3c72fd96b14709fb35a9cc28daf 100644
--- a/chrome/browser/printing/printer_query_oop.cc
+++ b/chrome/browser/printing/printer_query_oop.cc
@@ -126,7 +126,7 @@ void PrinterQueryOop::OnDidAskUserForSettings(
@@ -632,7 +632,7 @@ index dc2a15ab4d784b0b6c85b84a30c3c08a17ed8e3d..e197026e8a7f132c1bf90a0f5f1eabb4
// Want the same PrintBackend service as the query so that we use the same
// device context.
print_document_client_id_ =
@@ -189,6 +189,21 @@ void PrinterQueryOop::GetSettingsWithUI(uint32_t document_page_count,
@@ -189,6 +189,28 @@ void PrinterQueryOop::GetSettingsWithUI(uint32_t document_page_count,
// browser process.
// - Other platforms don't have a system print UI or do not use OOP
// printing, so this does not matter.
@@ -643,12 +643,19 @@ index dc2a15ab4d784b0b6c85b84a30c3c08a17ed8e3d..e197026e8a7f132c1bf90a0f5f1eabb4
+ // remote service context, not the local one used by the native dialog.
+ if (settings().dpi()) {
+ printing_context()->SetPrintSettings(settings());
+ printing_context()->UpdatePrinterSettings(PrintingContext::PrinterSettings{
+ if (printing_context()->UpdatePrinterSettings(
+ PrintingContext::PrinterSettings{
+#if BUILDFLAG(IS_MAC)
+ .external_preview = false,
+ .external_preview = false,
+#endif
+ .show_system_dialog = false,
+ });
+ .show_system_dialog = false,
+ }) != mojom::ResultCode::kSuccess) {
+ // Prefilling failed (e.g. the printer does not support the requested
+ // resolution). Reinitialize with defaults so that AskUserForSettings
+ // does not crash due to a null print_info_. The dialog will simply
+ // open without prefilled values.
+ printing_context()->UseDefaultSettings();
+ }
+ }
+
PrinterQuery::GetSettingsWithUI(

View File

@@ -990,17 +990,15 @@ std::string App::GetLocaleCountryCode() {
WCHAR locale_name[LOCALE_NAME_MAX_LENGTH] = {0};
if (GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SISO3166CTRYNAME,
(LPWSTR)&locale_name,
sizeof(locale_name) / sizeof(WCHAR)) ||
locale_name, std::size(locale_name)) ||
GetLocaleInfoEx(LOCALE_NAME_SYSTEM_DEFAULT, LOCALE_SISO3166CTRYNAME,
(LPWSTR)&locale_name,
sizeof(locale_name) / sizeof(WCHAR))) {
locale_name, std::size(locale_name))) {
base::WideToUTF8(locale_name, wcslen(locale_name), &region);
}
#elif BUILDFLAG(IS_MAC)
CFLocaleRef locale = CFLocaleCopyCurrent();
CFStringRef value = CFStringRef(
static_cast<CFTypeRef>(CFLocaleGetValue(locale, kCFLocaleCountryCode)));
CFStringRef value =
static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleCountryCode));
if (value != nil) {
char temporaryCString[3];
const CFIndex kCStringSize = sizeof(temporaryCString);

View File

@@ -972,11 +972,12 @@ WebContents::WebContents(v8::Isolate* isolate,
void WebContents::InitZoomController(content::WebContents* web_contents,
const gin_helper::Dictionary& options) {
WebContentsZoomController::CreateForWebContents(web_contents);
zoom_controller_ = WebContentsZoomController::FromWebContents(web_contents);
WebContentsZoomController* const zoom_controller =
WebContentsZoomController::GetOrCreateForWebContents(web_contents);
double zoom_factor;
if (options.Get(options::kZoomFactor, &zoom_factor))
zoom_controller_->SetDefaultZoomFactor(zoom_factor);
zoom_controller->SetDefaultZoomFactor(zoom_factor);
// Nothing to do with ZoomController, but this function gets called in all
// init cases!
@@ -3152,16 +3153,18 @@ void OnGetDeviceNameToUse(base::WeakPtr<content::WebContents> web_contents,
.Set(printing::kSettingMediaSizeIsDefault, true);
};
const bool use_default_size =
print_settings.FindBool(kUseDefaultPrinterPageSize).value_or(false);
std::optional<gfx::Size> paper_size;
if (use_default_size)
paper_size = GetPrinterDefaultPaperSize(base::UTF16ToUTF8(info.second));
if (!print_settings.Find(printing::kSettingMediaSize)) {
const bool use_default_size =
print_settings.FindBool(kUseDefaultPrinterPageSize).value_or(false);
std::optional<gfx::Size> paper_size;
if (use_default_size)
paper_size = GetPrinterDefaultPaperSize(base::UTF16ToUTF8(info.second));
print_settings.Set(
printing::kSettingMediaSize,
paper_size ? make_media_size(paper_size->height(), paper_size->width())
: make_media_size(297000, 210000));
print_settings.Set(
printing::kSettingMediaSize,
paper_size ? make_media_size(paper_size->height(), paper_size->width())
: make_media_size(297000, 210000));
}
content::RenderFrameHost* rfh = GetRenderFrameHostToUse(web_contents.get());
if (!rfh)
@@ -3867,12 +3870,16 @@ gfx::Size WebContents::GetSizeForNewRenderView(content::WebContents* wc) {
return {};
}
WebContentsZoomController* WebContents::GetZoomController() const {
return WebContentsZoomController::FromWebContents(web_contents());
}
void WebContents::SetZoomLevel(double level) {
zoom_controller_->SetZoomLevel(level);
GetZoomController()->SetZoomLevel(level);
}
double WebContents::GetZoomLevel() const {
return zoom_controller_->GetZoomLevel();
return GetZoomController()->GetZoomLevel();
}
void WebContents::SetZoomFactor(gin_helper::ErrorThrower thrower,
@@ -3892,7 +3899,7 @@ double WebContents::GetZoomFactor() const {
}
void WebContents::SetTemporaryZoomLevel(double level) {
zoom_controller_->SetTemporaryZoomLevel(level);
GetZoomController()->SetTemporaryZoomLevel(level);
}
std::optional<PreloadScript> WebContents::GetPreloadScript() const {

View File

@@ -380,7 +380,7 @@ class WebContents final : public ExclusiveAccessContext,
content::RenderFrameHost* Opener();
content::RenderFrameHost* FocusedFrame();
WebContentsZoomController* GetZoomController() { return zoom_controller_; }
[[nodiscard]] WebContentsZoomController* GetZoomController() const;
void AddObserver(ExtendedWebContentsObserver* obs) {
observers_.AddObserver(obs);
@@ -858,11 +858,6 @@ class WebContents final : public ExclusiveAccessContext,
// destroyed before dialog_manager_, otherwise a crash would happen.
std::unique_ptr<InspectableWebContents> inspectable_web_contents_;
// The zoom controller for this webContents.
// Note: owned by inspectable_web_contents_, so declare this *after*
// that field to ensure the dtor destroys them in the right order.
raw_ptr<WebContentsZoomController> zoom_controller_ = nullptr;
std::optional<GURL> pending_unload_url_ = std::nullopt;
// Maps url to file path, used by the file requests sent from devtools.

View File

@@ -184,7 +184,7 @@ std::vector<std::string> Browser::GetRecentDocuments() {
std::vector<std::string> documents;
documents.reserve([recentURLs count]);
for (NSURL* url in recentURLs)
documents.push_back(std::string([url.path UTF8String]));
documents.emplace_back([url.path UTF8String]);
return documents;
}

View File

@@ -455,9 +455,9 @@ void BrowserProcessImpl::CreateOSCryptAsync() {
// The DPAPI key provider requires OSCrypt::Init to have already been called
// to initialize the key storage. This happens in
// BrowserMainPartsWin::PreCreateMainMessageLoop.
providers.emplace_back(std::make_pair(
providers.emplace_back(
/*precedence=*/10u,
std::make_unique<os_crypt_async::DPAPIKeyProvider>(local_state())));
std::make_unique<os_crypt_async::DPAPIKeyProvider>(local_state()));
#endif // BUILDFLAG(IS_WIN)
#if BUILDFLAG(IS_LINUX)
@@ -499,9 +499,9 @@ void BrowserProcessImpl::CreateOSCryptAsync() {
#if BUILDFLAG(IS_MAC)
if (base::FeatureList::IsEnabled(features::kUseKeychainKeyProvider)) {
providers.emplace_back(std::make_pair(
providers.emplace_back(
/*precedence=*/10u,
std::make_unique<os_crypt_async::KeychainKeyProvider>()));
std::make_unique<os_crypt_async::KeychainKeyProvider>());
}
#endif // BUILDFLAG(IS_MAC)

View File

@@ -398,9 +398,7 @@ ExtensionFunction::ResponseAction TabsGetZoomFunction::Run() {
if (!contents)
return RespondNow(Error("No such tab"));
double zoom_level = contents->GetZoomController()->GetZoomLevel();
double zoom_factor = blink::ZoomLevelToZoomFactor(zoom_level);
const double zoom_factor = contents->GetZoomFactor();
return RespondNow(ArgumentList(tabs::GetZoom::Results::Create(zoom_factor)));
}
@@ -414,9 +412,9 @@ ExtensionFunction::ResponseAction TabsGetZoomSettingsFunction::Run() {
if (!contents)
return RespondNow(Error("No such tab"));
auto* zoom_controller = contents->GetZoomController();
WebContentsZoomController::ZoomMode zoom_mode =
contents->GetZoomController()->zoom_mode();
const auto* zoom_controller = contents->GetZoomController();
const WebContentsZoomController::ZoomMode zoom_mode =
zoom_controller->zoom_mode();
tabs::ZoomSettings zoom_settings;
ZoomModeToZoomSettings(zoom_mode, &zoom_settings);
zoom_settings.default_zoom_factor =

View File

@@ -208,7 +208,7 @@ inline void dispatch_sync_main(dispatch_block_t block) {
forEventClass:kInternetEventClass
andEventID:kAEGetURL];
handoffLock_ = [NSCondition new];
handoffLock_ = [[NSCondition alloc] init];
}
- (void)handleURLEvent:(NSAppleEventDescriptor*)event

View File

@@ -96,7 +96,7 @@ class NativeWindow : public views::WidgetDelegate {
virtual void SetFullScreen(bool fullscreen) = 0;
virtual bool IsFullscreen() const = 0;
virtual void SetBounds(const gfx::Rect& bounds, bool animate = false) = 0;
virtual void SetBounds(const gfx::Rect& bounds, bool animate) = 0;
virtual gfx::Rect GetBounds() const = 0;
void SetShape(const std::vector<gfx::Rect>& rects);
void SetSize(const gfx::Size& size, bool animate = false);

View File

@@ -59,7 +59,7 @@ class NativeWindowMac : public NativeWindow,
bool IsMinimized() const override;
void SetFullScreen(bool fullscreen) override;
bool IsFullscreen() const override;
void SetBounds(const gfx::Rect& bounds, bool animate = false) override;
void SetBounds(const gfx::Rect& bounds, bool animate) override;
gfx::Rect GetBounds() const override;
bool IsNormal() const override;
gfx::Rect GetNormalBounds() const override;

View File

@@ -1269,7 +1269,7 @@ void NativeWindowViews::SetBackgroundColor(SkColor background_color) {
SetClassLongPtr(GetAcceleratedWidget(), GCLP_HBRBACKGROUND,
reinterpret_cast<LONG_PTR>(brush));
if (previous_brush)
DeleteObject((HBRUSH)previous_brush);
DeleteObject(reinterpret_cast<HBRUSH>(previous_brush));
InvalidateRect(GetAcceleratedWidget(), nullptr, 1);
#endif
SkColor compositor_color = background_color;
@@ -1468,11 +1468,11 @@ void NativeWindowViews::SetParentWindow(NativeWindow* parent) {
// the ::GetWindowLongPtr or ::SetWindowLongPtr functions with "nIndex" set
// to "GWLP_HWNDPARENT" which actually means the window owner.
HWND hwndParent = parent ? parent->GetAcceleratedWidget() : nullptr;
if (hwndParent ==
(HWND)::GetWindowLongPtr(GetAcceleratedWidget(), GWLP_HWNDPARENT))
if (hwndParent == reinterpret_cast<HWND>(::GetWindowLongPtr(
GetAcceleratedWidget(), GWLP_HWNDPARENT)))
return;
::SetWindowLongPtr(GetAcceleratedWidget(), GWLP_HWNDPARENT,
(LONG_PTR)hwndParent);
reinterpret_cast<LONG_PTR>(hwndParent));
// Ensures the visibility
if (IsVisible()) {
WINDOWPLACEMENT wp;

View File

@@ -155,10 +155,9 @@ bool AuthorizedInstall(NSString* srcPath, NSString* dstPath, bool* canceled) {
AuthorizationItem myItems = {kAuthorizationRightExecute, 0, nullptr, 0};
AuthorizationRights myRights = {1, &myItems};
AuthorizationFlags myFlags =
(AuthorizationFlags)(kAuthorizationFlagInteractionAllowed |
kAuthorizationFlagExtendRights |
kAuthorizationFlagPreAuthorize);
AuthorizationFlags myFlags = kAuthorizationFlagInteractionAllowed |
kAuthorizationFlagExtendRights |
kAuthorizationFlagPreAuthorize;
err = AuthorizationCopyRights(myAuthorizationRef, &myRights, nullptr, myFlags,
nullptr);

View File

@@ -49,7 +49,7 @@ static StartGridAnimationIMP g_orig_startGridAnimation = nullptr;
static void Patched_startGridAnimation(id self,
SEL _cmd,
id animation,
void (^completionHandler)(void)) {
void (^completionHandler)()) {
if (completionHandler)
completionHandler();
}
@@ -83,8 +83,7 @@ MouseDownImpl g_nsnextstepframe_mousedown;
@implementation SwizzledMethodsClass
- (void)swiz_nsthemeframe_mouseDown:(NSEvent*)event {
if ([self.window respondsToSelector:@selector(shell)]) {
electron::NativeWindowMac* shell =
(electron::NativeWindowMac*)[(id)self.window shell];
electron::NativeWindowMac* shell = [(id)self.window shell];
if (shell && !shell->has_frame())
[self cr_mouseDownOnFrameView:event];
}
@@ -93,8 +92,7 @@ MouseDownImpl g_nsnextstepframe_mousedown;
- (void)swiz_nsnextstepframe_mouseDown:(NSEvent*)event {
if ([self.window respondsToSelector:@selector(shell)]) {
electron::NativeWindowMac* shell =
(electron::NativeWindowMac*)[(id)self.window shell];
electron::NativeWindowMac* shell = [(id)self.window shell];
if (shell && !shell->has_frame()) {
[self cr_mouseDownOnFrameView:event];
}
@@ -104,8 +102,7 @@ MouseDownImpl g_nsnextstepframe_mousedown;
- (void)swiz_nsview_swipeWithEvent:(NSEvent*)event {
if ([self.window respondsToSelector:@selector(shell)]) {
electron::NativeWindowMac* shell =
(electron::NativeWindowMac*)[(id)self.window shell];
electron::NativeWindowMac* shell = [(id)self.window shell];
if (shell) {
if (event.deltaY == 1.0) {
shell->NotifyWindowSwipe("up");

View File

@@ -80,7 +80,7 @@ NSAlert* CreateNSAlert(const MessageBoxSettings& settings) {
// TODO(@codebytere): This behavior violates HIG & should be deprecated.
if (settings.cancel_id == settings.default_id) {
[(NSButton*)[ns_buttons objectAtIndex:settings.default_id] highlight:YES];
[[ns_buttons objectAtIndex:settings.default_id] highlight:YES];
}
}

View File

@@ -87,7 +87,7 @@ WinCaptionButtonContainer::WinCaptionButtonContainer(WinFrameView* frame_view)
UpdateButtonToolTipsForWindowControlsOverlay();
}
WinCaptionButtonContainer::~WinCaptionButtonContainer() {}
WinCaptionButtonContainer::~WinCaptionButtonContainer() = default;
int WinCaptionButtonContainer::NonClientHitTest(const gfx::Point& point) const {
DCHECK(HitTestPoint(point))

View File

@@ -198,12 +198,10 @@ NotifyIcon* NotifyIconHost::CreateNotifyIcon(std::optional<base::Uuid> guid) {
guid_str = guid_str.substr(1, guid_str.length() - 2);
}
unsigned char* uid_cstr = (unsigned char*)guid_str.c_str();
auto* uid_cstr = reinterpret_cast<unsigned char*>(guid_str.data());
RPC_STATUS result = UuidFromStringA(uid_cstr, &uid);
if (result != RPC_S_INVALID_STRING_UUID) {
for (NotifyIcons::const_iterator i(notify_icons_.begin());
i != notify_icons_.end(); ++i) {
auto* current_win_icon = static_cast<NotifyIcon*>(*i);
for (const NotifyIcon* current_win_icon : notify_icons_) {
if (current_win_icon->guid() == uid) {
LOG(WARNING)
<< "Guid already in use. Existing tray entry will be replaced.";
@@ -256,9 +254,7 @@ LRESULT CALLBACK NotifyIconHost::WndProc(HWND hwnd,
NotifyIcon* win_icon = nullptr;
// Find the selected status icon.
for (NotifyIcons::const_iterator i(notify_icons_.begin());
i != notify_icons_.end(); ++i) {
auto* current_win_icon = static_cast<NotifyIcon*>(*i);
for (NotifyIcon* current_win_icon : notify_icons_) {
if (current_win_icon->icon_id() == wparam) {
win_icon = current_win_icon;
break;

View File

@@ -76,7 +76,7 @@ struct Converter<UUID> {
if (guid[0] == '{' && guid[guid.length() - 1] == '}') {
guid = guid.substr(1, guid.length() - 2);
}
unsigned char* uid_cstr = (unsigned char*)guid.c_str();
auto* uid_cstr = reinterpret_cast<unsigned char*>(guid.data());
RPC_STATUS result = UuidFromStringA(uid_cstr, &uid);
if (result == RPC_S_INVALID_STRING_UUID) {
return false;

View File

@@ -167,13 +167,9 @@ void OpenExternal(const GURL& url,
configuration:configuration
completionHandler:^(NSRunningApplication* _Nullable app,
NSError* _Nullable error) {
if (error) {
runner->PostTask(FROM_HERE, base::BindOnce(std::move(copied_callback),
"Failed to open URL"));
} else {
runner->PostTask(FROM_HERE,
base::BindOnce(std::move(copied_callback), ""));
}
std::string err_msg = error ? "Failed to open URL" : "";
runner->PostTask(FROM_HERE, base::BindOnce(std::move(copied_callback),
std::move(err_msg)));
}];
}