mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Compare commits
16 Commits
remove-dec
...
chore/clan
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e7689cd30 | ||
|
|
7adcfe1027 | ||
|
|
496f0946f0 | ||
|
|
847c5e0613 | ||
|
|
a36b3b1849 | ||
|
|
92a7a12cc8 | ||
|
|
860840cdeb | ||
|
|
d0c1465045 | ||
|
|
7d492877ea | ||
|
|
e17567b307 | ||
|
|
cf9a79962c | ||
|
|
b6ac415084 | ||
|
|
62e637275a | ||
|
|
28c0eb29df | ||
|
|
8a730e2aec | ||
|
|
044be7ce40 |
@@ -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' };
|
||||
});
|
||||
|
||||
|
||||
@@ -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()`
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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), ®ion);
|
||||
}
|
||||
#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);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)));
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user