electron/shell/browser/ui/tray_icon_cocoa.mm

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

398 lines
12 KiB
Text
Raw Normal View History

// Copyright (c) 2014 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/browser/ui/tray_icon_cocoa.h"
#include <string>
#include <vector>
#include "base/message_loop/message_pump_mac.h"
#include "base/strings/sys_string_conversions.h"
#include "base/task/current_thread.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "shell/browser/ui/cocoa/NSString+ANSI.h"
#include "shell/browser/ui/cocoa/electron_menu_controller.h"
#include "ui/events/cocoa/cocoa_event_utils.h"
2016-06-21 06:40:30 +00:00
#include "ui/gfx/mac/coordinate_conversion.h"
#include "ui/native_theme/native_theme.h"
@interface StatusItemView : NSView {
2018-04-20 18:47:04 +00:00
electron::TrayIconCocoa* trayIcon_; // weak
ElectronMenuController* menuController_; // weak
BOOL ignoreDoubleClickEvents_;
base::scoped_nsobject<NSStatusItem> statusItem_;
base::scoped_nsobject<NSTrackingArea> trackingArea_;
}
@end // @interface StatusItemView
@implementation StatusItemView
- (void)dealloc {
trayIcon_ = nil;
menuController_ = nil;
[super dealloc];
}
- (id)initWithIcon:(electron::TrayIconCocoa*)icon {
trayIcon_ = icon;
menuController_ = nil;
ignoreDoubleClickEvents_ = NO;
2018-04-20 18:47:04 +00:00
if ((self = [super initWithFrame:CGRectZero])) {
[self registerForDraggedTypes:@[
2016-07-14 17:21:39 +00:00
NSFilenamesPboardType,
NSStringPboardType,
]];
// Create the status item.
2018-04-20 18:47:04 +00:00
NSStatusItem* item = [[NSStatusBar systemStatusBar]
statusItemWithLength:NSVariableStatusItemLength];
statusItem_.reset([item retain]);
[[statusItem_ button] addSubview:self]; // inject custom view
[self updateDimensions];
}
return self;
}
- (void)updateDimensions {
[self setFrame:[statusItem_ button].frame];
}
- (void)updateTrackingAreas {
// Use NSTrackingArea for listening to mouseEnter, mouseExit, and mouseMove
// events.
[self removeTrackingArea:trackingArea_];
trackingArea_.reset([[NSTrackingArea alloc]
initWithRect:[self bounds]
options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved |
NSTrackingActiveAlways
owner:self
userInfo:nil]);
[self addTrackingArea:trackingArea_];
}
- (void)removeItem {
// Turn off tracking events to prevent crash.
if (trackingArea_) {
[self removeTrackingArea:trackingArea_];
trackingArea_.reset();
}
[[NSStatusBar systemStatusBar] removeStatusItem:statusItem_];
[self removeFromSuperview];
statusItem_.reset();
}
- (void)setImage:(NSImage*)image {
[[statusItem_ button] setImage:image];
[self updateDimensions];
}
- (void)setAlternateImage:(NSImage*)image {
[[statusItem_ button] setAlternateImage:image];
// We need to change the button type here because the default button type for
// NSStatusItem, NSStatusBarButton, does not display alternate content when
// clicked. NSButtonTypeMomentaryChange displays its alternate content when
// clicked and returns to its normal content when the user releases it, which
// is the behavior users would expect when clicking a button with an alternate
// image set.
[[statusItem_ button] setButtonType:NSButtonTypeMomentaryChange];
[self updateDimensions];
}
- (void)setIgnoreDoubleClickEvents:(BOOL)ignore {
ignoreDoubleClickEvents_ = ignore;
}
- (BOOL)getIgnoreDoubleClickEvents {
return ignoreDoubleClickEvents_;
}
- (void)setTitle:(NSString*)title font_type:(NSString*)font_type {
NSMutableAttributedString* attributed_title =
[[NSMutableAttributedString alloc] initWithString:title];
if ([title containsANSICodes]) {
attributed_title = [title attributedStringParsingANSICodes];
}
// Change font type, if specified
CGFloat existing_size = [[[statusItem_ button] font] pointSize];
if ([font_type isEqualToString:@"monospaced"]) {
if (@available(macOS 10.15, *)) {
NSDictionary* attributes = @{
NSFontAttributeName :
[NSFont monospacedSystemFontOfSize:existing_size
weight:NSFontWeightRegular]
};
[attributed_title
addAttributes:attributes
range:NSMakeRange(0, [attributed_title length])];
}
} else if ([font_type isEqualToString:@"monospacedDigit"]) {
NSDictionary* attributes = @{
NSFontAttributeName :
[NSFont monospacedDigitSystemFontOfSize:existing_size
weight:NSFontWeightRegular]
};
[attributed_title addAttributes:attributes
range:NSMakeRange(0, [attributed_title length])];
}
// Set title
[[statusItem_ button] setAttributedTitle:attributed_title];
// Fix icon margins.
if (title.length > 0) {
[[statusItem_ button] setImagePosition:NSImageLeft];
} else {
[[statusItem_ button] setImagePosition:NSImageOnly];
}
[self updateDimensions];
}
- (NSString*)title {
return [statusItem_ button].title;
2017-11-09 22:21:39 +00:00
}
- (void)setMenuController:(ElectronMenuController*)menu {
menuController_ = menu;
[statusItem_ setMenu:[menuController_ menu]];
}
- (void)handleClickNotifications:(NSEvent*)event {
// If we are ignoring double click events, we should ignore the `clickCount`
// value and immediately emit a click event.
BOOL shouldBeHandledAsASingleClick =
(event.clickCount == 1) || ignoreDoubleClickEvents_;
if (shouldBeHandledAsASingleClick)
trayIcon_->NotifyClicked(
2016-06-21 06:40:30 +00:00
gfx::ScreenRectFromNSRect(event.window.frame),
2017-10-05 02:49:26 +00:00
gfx::ScreenPointFromNSPoint([event locationInWindow]),
ui::EventFlagsFromModifiers([event modifierFlags]));
// Double click event.
BOOL shouldBeHandledAsADoubleClick =
(event.clickCount == 2) && !ignoreDoubleClickEvents_;
if (shouldBeHandledAsADoubleClick)
trayIcon_->NotifyDoubleClicked(
2016-06-21 06:40:30 +00:00
gfx::ScreenRectFromNSRect(event.window.frame),
ui::EventFlagsFromModifiers([event modifierFlags]));
}
- (void)mouseDown:(NSEvent*)event {
trayIcon_->NotifyMouseDown(
gfx::ScreenPointFromNSPoint([event locationInWindow]),
ui::EventFlagsFromModifiers([event modifierFlags]));
// Pass click to superclass to show menu if one exists and has a non-zero
// number of items. Custom mouseUp handler won't be invoked in this case.
if (menuController_ && [[menuController_ menu] numberOfItems] > 0) {
[self handleClickNotifications:event];
[super mouseDown:event];
} else {
[[statusItem_ button] highlight:YES];
}
}
- (void)mouseUp:(NSEvent*)event {
[[statusItem_ button] highlight:NO];
trayIcon_->NotifyMouseUp(
gfx::ScreenPointFromNSPoint([event locationInWindow]),
ui::EventFlagsFromModifiers([event modifierFlags]));
[self handleClickNotifications:event];
}
- (void)popUpContextMenu:(electron::ElectronMenuModel*)menu_model {
// Make sure events can be pumped while the menu is up.
chore: bump chromium to 110.0.5451.0 (main) (#36394) * chore: bump chromium in DEPS to 110.0.5425.0 * chore: bump chromium in DEPS to 110.0.5427.0 * chore: bump chromium in DEPS to 110.0.5429.0 * chore: bump chromium in DEPS to 110.0.5431.0 * chore: update patches/chromium/picture-in-picture.patch to fix upstream code shear https://chromium-review.googlesource.com/c/chromium/src/+/4024078 * chore: sync patch w/upstream shear: remove_usage_of_incognito_apis_in_the_spellchecker.patch https://chromium-review.googlesource.com/c/chromium/src/+/3967854 * chore: sync patch w/upstream shear: feat_expose_raw_response_headers_from_urlloader.patch https://chromium-review.googlesource.com/c/chromium/src/+/3983373 * chore: sync patch w/upstream shear: chromium/custom_protocols_plzserviceworker.patch https://chromium-review.googlesource.com/c/chromium/src/+/3983373 * build: update references to core_api_provider; its location was moved upstream Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4006696 * build: remove back_to_tab_image_button from our enable_picture_in_picture deps Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4024078 back_to_tab_image_button has been removed upstream * chore: update patches * chore: bump chromium in DEPS to 110.0.5433.0 * chore: sync patch w/upstream shear: chromium/printing.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4006638 * chore: sync patch w/trivial upstream shear: chromium/process_singleton.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4031817 * refactor: remove kAutofillCenterAlignedSuggestions feature flag check. This behavior had been an experiment behind a feature flag. The experiment was a success so the feature was kept & the flag was removed. Xref: https://chromium-review.googlesource.com/c/chromium/src/+/3870616 moves from disabled-by-default to enabled-by-default Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4030556 removed the feature flag * chore: update patches * chore: bump chromium in DEPS to 110.0.5435.0 * chore: update patches * chore: sync code with upstream change: AXLMode method name Xref: https://chromium-review.googlesource.com/c/chromium/src/+/3950054 * 3841761: Adapting code to support kSystemProfileSelectionDefaultNone experiment https://chromium-review.googlesource.com/c/chromium/src/+/3841761 * chore: bump chromium in DEPS to 110.0.5437.0 * 4040140: Pip 2.0: Merge VideoOverlayWindowViews and OverlayWindowViews https://chromium-review.googlesource.com/c/chromium/src/+/4040140 * 4045567: Fix a crash opening a popup from tab capture fullscreen https://chromium-review.googlesource.com/c/chromium/src/+/4045567 * chore: fixup patch indices * 4048263: Remove deprecated Value calls in frame_tracker_unittest.cc. https://chromium-review.googlesource.com/c/chromium/src/+/4048263 * 4004606: [intl] Migrate to ICU 72 https://chromium-review.googlesource.com/c/v8/v8/+/4004606 * chore: bump chromium in DEPS to 110.0.5439.0 * 3890670: Prerender: Add first implementation of prerender-in-new-tab mode https://chromium-review.googlesource.com/c/chromium/src/+/3890670 * chore: fixup patch indices * chore: bump chromium in DEPS to 110.0.5441.0 * chore: update patches * chore: bump chromium in DEPS to 110.0.5443.0 * 4035451: Remove remaining uses of ScopedNestableTaskAllower. https://chromium-review.googlesource.com/c/chromium/src/+/4035451 * chore: bump chromium in DEPS to 110.0.5445.0 * chore: update patches * fixup! 3890670: Prerender: Add first implementation of prerender-in-new-tab mode * test: disable parallel/test-worker-init-failure Refs https://chromium-review.googlesource.com/c/v8/v8/+/4017512 Refs https://github.com/nodejs/node-v8/issues/246 * chore: disable parallel/test-fetch Test is flaky on Linux CI, but runs fine locally. * chore: bump chromium in DEPS to 110.0.5451.0 * chore: update patches * chore: cleanup patch Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: electron-patch-conflict-fixer[bot] <83340002+electron-patch-conflict-fixer[bot]@users.noreply.github.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2022-12-05 22:59:19 +00:00
base::CurrentThread::ScopedAllowApplicationTasksInNativeNestedLoop allow;
2015-12-02 11:05:22 +00:00
// Show a custom menu.
if (menu_model) {
base::scoped_nsobject<ElectronMenuController> menuController(
[[ElectronMenuController alloc] initWithModel:menu_model
useDefaultAccelerator:NO]);
// Hacky way to mimic design of ordinary tray menu.
[statusItem_ setMenu:[menuController menu]];
// -performClick: is a blocking call, which will run the task loop inside
// itself. This can potentially include running JS, which can result in
// this object being released. We take a temporary reference here to make
// sure we stay alive long enough to successfully return from this
// function.
// TODO(nornagon/codebytere): Avoid nesting task loops here.
[self retain];
[[statusItem_ button] performClick:self];
[statusItem_ setMenu:[menuController_ menu]];
[self release];
2015-12-02 11:05:22 +00:00
return;
}
if (menuController_ && ![menuController_ isMenuOpen]) {
// Ensure the UI can update while the menu is fading out.
base::ScopedPumpMessagesInPrivateModes pump_private;
[[statusItem_ button] performClick:self];
}
}
- (void)closeContextMenu {
if (menuController_) {
[menuController_ cancel];
}
}
- (void)rightMouseUp:(NSEvent*)event {
trayIcon_->NotifyRightClicked(
2016-06-21 06:40:30 +00:00
gfx::ScreenRectFromNSRect(event.window.frame),
ui::EventFlagsFromModifiers([event modifierFlags]));
}
2018-04-20 18:47:04 +00:00
- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender {
trayIcon_->NotifyDragEntered();
return NSDragOperationCopy;
}
- (void)mouseExited:(NSEvent*)event {
trayIcon_->NotifyMouseExited(
gfx::ScreenPointFromNSPoint([event locationInWindow]),
ui::EventFlagsFromModifiers([event modifierFlags]));
}
- (void)mouseEntered:(NSEvent*)event {
trayIcon_->NotifyMouseEntered(
gfx::ScreenPointFromNSPoint([event locationInWindow]),
ui::EventFlagsFromModifiers([event modifierFlags]));
}
- (void)mouseMoved:(NSEvent*)event {
trayIcon_->NotifyMouseMoved(
gfx::ScreenPointFromNSPoint([event locationInWindow]),
ui::EventFlagsFromModifiers([event modifierFlags]));
}
2018-04-20 18:47:04 +00:00
- (void)draggingExited:(id<NSDraggingInfo>)sender {
trayIcon_->NotifyDragExited();
}
2018-04-20 18:47:04 +00:00
- (void)draggingEnded:(id<NSDraggingInfo>)sender {
2015-11-10 16:02:50 +00:00
trayIcon_->NotifyDragEnded();
if (NSPointInRect([sender draggingLocation], self.frame)) {
trayIcon_->NotifyDrop();
}
2015-11-10 16:02:50 +00:00
}
2018-04-20 18:47:04 +00:00
- (BOOL)handleDrop:(id<NSDraggingInfo>)sender {
NSPasteboard* pboard = [sender draggingPasteboard];
if ([[pboard types] containsObject:NSFilenamesPboardType]) {
std::vector<std::string> dropFiles;
NSArray* files = [pboard propertyListForType:NSFilenamesPboardType];
for (NSString* file in files)
dropFiles.push_back(base::SysNSStringToUTF8(file));
2015-10-18 05:32:13 +00:00
trayIcon_->NotifyDropFiles(dropFiles);
return YES;
2016-07-14 17:21:39 +00:00
} else if ([[pboard types] containsObject:NSStringPboardType]) {
NSString* dropText = [pboard stringForType:NSStringPboardType];
trayIcon_->NotifyDropText(base::SysNSStringToUTF8(dropText));
return YES;
}
2016-07-14 17:21:39 +00:00
return NO;
}
2018-04-20 18:47:04 +00:00
- (BOOL)prepareForDragOperation:(id<NSDraggingInfo>)sender {
return YES;
}
2018-04-20 18:47:04 +00:00
- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
2016-11-20 05:18:24 +00:00
[self handleDrop:sender];
return YES;
}
@end
namespace electron {
TrayIconCocoa::TrayIconCocoa() {
status_item_view_.reset([[StatusItemView alloc] initWithIcon:this]);
}
TrayIconCocoa::~TrayIconCocoa() {
[status_item_view_ removeItem];
}
void TrayIconCocoa::SetImage(const gfx::Image& image) {
[status_item_view_ setImage:image.AsNSImage()];
}
void TrayIconCocoa::SetPressedImage(const gfx::Image& image) {
[status_item_view_ setAlternateImage:image.AsNSImage()];
}
void TrayIconCocoa::SetToolTip(const std::string& tool_tip) {
[status_item_view_ setToolTip:base::SysUTF8ToNSString(tool_tip)];
}
void TrayIconCocoa::SetTitle(const std::string& title,
const TitleOptions& options) {
[status_item_view_ setTitle:base::SysUTF8ToNSString(title)
font_type:base::SysUTF8ToNSString(options.font_type)];
}
std::string TrayIconCocoa::GetTitle() {
return base::SysNSStringToUTF8([status_item_view_ title]);
}
void TrayIconCocoa::SetIgnoreDoubleClickEvents(bool ignore) {
[status_item_view_ setIgnoreDoubleClickEvents:ignore];
}
bool TrayIconCocoa::GetIgnoreDoubleClickEvents() {
return [status_item_view_ getIgnoreDoubleClickEvents];
}
void TrayIconCocoa::PopUpOnUI(ElectronMenuModel* menu_model) {
[status_item_view_ popUpContextMenu:menu_model];
}
void TrayIconCocoa::PopUpContextMenu(const gfx::Point& pos,
ElectronMenuModel* menu_model) {
chore: bump chromium to 103.0.5046.0 (main) (#33906) * chore: bump chromium in DEPS to 103.0.5020.0 * chore: bump chromium in DEPS to 103.0.5022.0 * chore: bump chromium in DEPS to 103.0.5024.0 * chore: update patches * 3587410: [Printing] Remove JobEventDetails Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3587410 * chore: bump chromium in DEPS to 103.0.5026.0 * chore: update patches * 3577218: WebUI: Delete webui_resources.grd and related GN targets. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3577218 * chore: bump chromium in DEPS to 103.0.5028.0 * chore: update patches * 3579297: Convert UpdatePrintSettings() to use non-deprecated base::Value APIs. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3579297 * 3560622: serial: Add SerialPort.forget() method Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3560622 * 3581708: Restore original display when moving from tab-fullscreen to browser-fullscreen. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3581708 * chore: fix authorization flags lint error * 3583363: Remove net wrappers around base/strings/escape.h Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3583363 * fixup! 3560622: serial: Add SerialPort.forget() method Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3560622 * 3587589: Reland "Propagate the MIME type from DownloadTargetDeterminer to DownloadItem" Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3587589 * 3584006: Remove IsRenderViewLive from content public Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3584006 * 3596174: [api] Remove APIs for resurrecting finalizers Ref: https://chromium-review.googlesource.com/c/v8/v8/+/3596174 * 3368244: Hook SnapshotForContentAnalysis renderer API to scan system prints Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3368244 * chore: bump chromium in DEPS to 103.0.5030.0 * chore: update patches * chore: bump chromium in DEPS to 103.0.5032.0 * chore: bump chromium in DEPS to 103.0.5034.0 * chore: bump chromium in DEPS to 103.0.5036.0 * chore: update patches * 3586363: Introduce PrintRenderFrame.PrintWithParams() for batch printing to PDF Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3586363 * 3593199: Remove content::PermissionType references and replace them with blink::PermissionType Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3593199 * 3368244: Hook SnapshotForContentAnalysis renderer API to scan system prints Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3368244 * chore: lint * chore: bump chromium in DEPS to 103.0.5038.0 * chore: update patches * fixup! 3560622: serial: Add SerialPort.forget() method * 3606495: mac screen capture: add metric Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3606495 * chore: bump chromium in DEPS to 103.0.5040.0 * chore: update patches * 3590840: Add IPs to DnsOverHttpsServerConfig https://chromium-review.googlesource.com/c/chromium/src/+/3590840 * stub functions for ElectronSerialDelegate and SerialChooserController to fix link * 3566412: [base] Remove base/android dependency on post_task.h and officially remove post_task.h! Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3566412 * 3347944: [content] No longer hand-off whole MainFunctionParams to BrowserMainParts Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3347944 * fixup! 3566412: [base] Remove base/android dependency on post_task.h and off… e3ea3e1 …icially remove post_task.h! * chore: update process_singleton patches for content::GetIOThreadTaskRunner({}) Ref: 2015655: [BrowserThread] Migrate co/pub/br and co/br/scheduler to the new API | https://chromium-review.googlesource.com/c/chromium/src/+/2015655 * chore: migrate base::DeleteSoon to content::GetUIThreadTaskRunner({})->DeleteSoon Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3566412 * chore: remove duplicate functions for RevokePortPermissionWebInitiated & GetPortInfo * chore: migrate Linux/Windows methods off of post_task.h Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3566412 * 64908: Stop building legacy SwiftShader GL in Chromium https://swiftshader-review.googlesource.com/c/SwiftShader/+/64908 * 3573245: Added Themed versions of RoundedRectBackground and RoundedRectBorder. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3573245 * chore: bump chromium in DEPS to 103.0.5042.0 * chore: update patches * 3571804: [api] Advance API deprecation for V8 version v10.2 https://chromium-review.googlesource.com/c/v8/v8/+/3571804 * fixup! 3571804: [api] Advance API deprecation for V8 version v10.2 * build: fix run-clang-format extension matching * lint * fix windows build * how is clang-format still not working for me * chore: update patches * 3623985: Replace ad-hoc SetPublicFirstPartySets calls with method in ContentBrowserClient. https://chromium-review.googlesource.com/c/chromium/src/+/3623985 * no need to implement WillProvidePublicFirstPartySets; the default is false * 3601036: [QT] Introduce ui/views/linux_ui/linux_ui_factory.* https://chromium-review.googlesource.com/c/chromium/src/+/3601036 * 3583363: Remove net wrappers around base/strings/escape.h https://chromium-review.googlesource.com/c/chromium/src/+/3583363 * lint * chore: bump chromium in DEPS to 103.0.5044.0 * fix conflicts * chore: update patches * upgrade nan * pin version of nan in tests * replace my hacky deprecated override fix with the fix from upstream * revert runtime dcheck in v8 * pin nan version at root too * refactor: tell gyp to use c++17 when building with our node * Revert "refactor: tell gyp to use c++17 when building with our node" This reverts commit 41a03a5799a8f40f31555d73d20ea865acfcd192. * Undo the reversion of 41a03a5799a8f40f31555d73d20ea865acfcd192. This reverts commit 54440abc598153bd7e259be4a908f0ecc0b33348. * disable sequential/test-cpu-prof-kill for now * also sequential/test-diagnostic-dir-cpu-prof Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Keeley Hammond <khammond@slack-corp.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: VerteDinde <vertedinde@electronjs.org> Co-authored-by: Jeremy Rose <japthorp@slack-corp.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> Co-authored-by: Jeremy Rose <jeremya@chromium.org> Co-authored-by: Charles Kerr <charles@charleskerr.com>
2022-05-17 16:48:40 +00:00
content::GetUIThreadTaskRunner({})->PostTask(
FROM_HERE,
base::BindOnce(&TrayIconCocoa::PopUpOnUI, weak_factory_.GetWeakPtr(),
base::Unretained(menu_model)));
}
void TrayIconCocoa::CloseContextMenu() {
[status_item_view_ closeContextMenu];
}
void TrayIconCocoa::SetContextMenu(ElectronMenuModel* menu_model) {
if (menu_model) {
// Create native menu.
menu_.reset([[ElectronMenuController alloc] initWithModel:menu_model
useDefaultAccelerator:NO]);
} else {
menu_.reset();
}
[status_item_view_ setMenuController:menu_.get()];
}
2016-06-21 06:40:30 +00:00
gfx::Rect TrayIconCocoa::GetBounds() {
return gfx::ScreenRectFromNSRect([status_item_view_ window].frame);
2015-08-10 04:48:22 +00:00
}
2014-05-30 15:57:54 +00:00
// static
chore: bump chromium to 93.0.4530.0 (master) (#29256) * chore: bump chromium in DEPS to 92.0.4512.6 * 2887336: [CaptureHandle][#2] Propagate CaptureHandleConfig in browser process https://chromium-review.googlesource.com/c/chromium/src/+/2887336 * refactor: base::Optional -> absl::optional * chore: fixup patch indices * chore: bump chromium in DEPS to 92.0.4514.0 * 2899417: Make build work when enable_pdf is set to false. https://chromium-review.googlesource.com/c/chromium/src/+/2899417 * 2904731: use BrowserContext instead of Profile in PreconnectManager https://chromium-review.googlesource.com/c/chromium/src/+/2904731 * 2295749: fix: check IsSecureEventInputEnabled in constructor before setting SetPasswordInputEnabled to true https://chromium-review.googlesource.com/c/chromium/src/+/2295749 * 2893803: Add a GetWebView to RenderFrame. https://chromium-review.googlesource.com/c/chromium/src/+/2893803 * 2892345: Implement WebContents::ForEachRenderFrameHost https://chromium-review.googlesource.com/c/chromium/src/+/2892345 * chore: fixup patch indices * 2892048: Real instance methods for BrowserContext: remaining 5 methods. https://chromium-review.googlesource.com/c/chromium/src/+/2892048 * 2902821: [mojo] Don't require full header includes for referenced interfaces https://chromium-review.googlesource.com/c/chromium/src/+/2902821 * 2496500: Remove last deprecated extension Event ctor. https://chromium-review.googlesource.com/c/chromium/src/+/2496500 * chore: fixup malformed pepper support patch * chore: bump chromium in DEPS to 92.0.4515.0 * 2908461: Add CreateEmptyPrintPagesParamsPtr() inside print_view_manager_base.cc. https://chromium-review.googlesource.com/c/chromium/src/+/2908461 * 2880838: viz: add optional HDRMetadata to TransferableResource https://chromium-review.googlesource.com/c/chromium/src/+/2880838 * chore: fixup patch indices * chore: bump chromium in DEPS to 92.0.4515.5 * chore: update patches * chore: bump chromium in DEPS to 92.0.4515.7 * chore: bump chromium in DEPS to 92.0.4515.9 * chore: bump chromium in DEPS to 93.0.4522.0 * chore: bump chromium in DEPS to 93.0.4523.0 * chore: bump chromium in DEPS to 93.0.4524.0 * chore: update patches * chore: enable_pak_file_integrity_checks was reverted * chore: update patches * refactor: base/optional was replaced with absl::optional Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2910202 * refactor: replace all usages of base::nullopt with absl::nullopt Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2910202 * chore: add missing base::Contains include Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2910202 * refactor: replace all usages of base::make_optional with absl::make_optional Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2910202 * refactor: replace WorldScriptContext() with GetScriptContextFromWorldId Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2893213 * chore: clean up left over opening namespace Refs: https://github.com/electron/electron/commit/95bfe6d08f65471394fb3005dbfa177cdf71210a * chore: add missing base::Contains include Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2910202 * refactor: replace GetCurrentDisplayIterator with the hard checker GetCurrentDisplay This code looks suspicious but if the iterator was invalid before it will also be invalid now. Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2893191 * refactor: headers are now passed directly in extensions client Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2918906 * refactor: base::DictionaryValue::empty() has been removed Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2912424 * chore: add missing includes for network URLLoaderFactory Refs: unknown, probably a side effect of header changes * refactor: make convenience wrapper around AppendArg There is no converter FromV8 for base::StringPiece (apparently its not possible). So we now take in an std::string and use the construct for StringPiece to do implicit conversion. Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2905544 * chore: add patch * chore: bump chromium in DEPS to 93.0.4525.0 * chore: update patches * refactor: CanResize has been de-virtualized Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2485774 * chore: update resource integrity patch * chore: add character encoding idl patch * chore: bump chromium in DEPS to 93.0.4526.0 * chore: update patches * chore: bump chromium in DEPS to 93.0.4527.0 * chore: bump chromium in DEPS to 93.0.4528.0 * chore: update patches * chore: update idl encoding patch * chore: bump chromium in DEPS to 93.0.4529.0 * chore: update patches * chore: bump chromium in DEPS to 93.0.4530.0 * chore: update patches * fix: only SetCanResize after the widget has been initialized * chore: add patch for vr on windows gn gen * spec: fix focus related tests on linux due to delay in focus swap * chore: remove new usages of base::Optional from main Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard <sattard@slack-corp.com> Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
2021-06-03 08:05:04 +00:00
TrayIcon* TrayIcon::Create(absl::optional<UUID> guid) {
2014-05-30 15:57:54 +00:00
return new TrayIconCocoa;
}
} // namespace electron