chore: bump chromium to 117.0.5892.0 (main) (#39118)

* chore: bump chromium in DEPS to 117.0.5892.0

* 4670267: Don't send javascript: or empty URLs to browser in CreateNewWindow.

4670267

* 4662090: Add metrics for WebGPU support

4662090

* 4672599: Use set_defaults for mac_app_bundle

4672599

* 4663771: usb: Add connection count tracking methods for UsbDelegate

4663771

* 4664578: Remove unused parameter from ExtensionsGuestViewManagerDelegate ctor

4664578

* 4622253: usb: Create classes for usb system tray icon

4622253

* 4678263: Remove ARC support from scoped_nsobject

4678263

* chore: follow-up ARC changes and missing guard corrections

* chore: don't mark 0-param ctor explicit

Follow up to 4664578

* chore: fixup patch indices

* 4670865: Merge ObjectProxy::CallMethodAndBlock{,WithErrorDetails}.

4670865

* chore: follow-up ARC changes and missing guard corrections

* fixup: retain ElectronApplicationDelegate

* fix: correct rustc binary

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
electron-roller[bot] 2023-07-19 00:26:27 +02:00 committed by GitHub
parent ee4460ac68
commit bbdd037219
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
77 changed files with 389 additions and 353 deletions

View file

@ -6,6 +6,10 @@
#include "base/apple/owned_objc.h"
#include "shell/browser/ui/cocoa/electron_inspectable_web_contents_view.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace electron {
DelayedNativeViewHost::DelayedNativeViewHost(gfx::NativeView native_view)

View file

@ -8,11 +8,14 @@
#import <AppKit/AppKit.h>
#include "base/apple/owned_objc.h"
#include "base/mac/scoped_nsobject.h"
#include "base/memory/raw_ptr.h"
#include "chrome/browser/devtools/devtools_contents_resizing_strategy.h"
#include "ui/base/cocoa/base_view.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace electron {
class InspectableWebContentsViewMac;
}
@ -27,8 +30,8 @@ using electron::InspectableWebContentsViewMac;
@private
raw_ptr<electron::InspectableWebContentsViewMac> inspectableWebContentsView_;
base::scoped_nsobject<NSView> fake_view_;
base::scoped_nsobject<NSWindow> devtools_window_;
NSView* __strong fake_view_;
NSWindow* __strong devtools_window_;
BOOL devtools_visible_;
BOOL devtools_docked_;
BOOL devtools_is_first_responder_;

View file

@ -13,6 +13,10 @@
#include "ui/base/cocoa/base_view.h"
#include "ui/gfx/mac/scoped_cocoa_disable_screen_updates.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation ElectronInspectableWebContentsView
- (instancetype)initWithInspectableWebContentsViewMac:
@ -28,7 +32,7 @@
attached_to_window_ = NO;
if (inspectableWebContentsView_->inspectable_web_contents()->IsGuest()) {
fake_view_.reset([[NSView alloc] init]);
fake_view_ = [[NSView alloc] init];
[fake_view_ setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[self addSubview:fake_view_];
} else {
@ -47,7 +51,6 @@
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
- (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize {
@ -126,7 +129,7 @@
} else {
[devtools_window_ setDelegate:nil];
[devtools_window_ close];
devtools_window_.reset();
devtools_window_ = nil;
}
}
}
@ -160,11 +163,11 @@
NSWindowStyleMaskResizable |
NSWindowStyleMaskTexturedBackground |
NSWindowStyleMaskUnifiedTitleAndToolbar;
devtools_window_.reset([[EventDispatchingWindow alloc]
devtools_window_ = [[EventDispatchingWindow alloc]
initWithContentRect:NSMakeRect(0, 0, 800, 600)
styleMask:styleMask
backing:NSBackingStoreBuffered
defer:YES]);
defer:YES];
[devtools_window_ setDelegate:self];
[devtools_window_ setFrameAutosaveName:@"electron.devtools"];
[devtools_window_ setTitle:@"Developer Tools"];

View file

@ -9,9 +9,12 @@
#import <Cocoa/Cocoa.h>
#include "base/functional/callback.h"
#include "base/mac/scoped_nsobject.h"
#include "base/memory/weak_ptr.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace electron {
class ElectronMenuModel;
}
@ -26,7 +29,9 @@ class ElectronMenuModel;
: NSObject <NSMenuDelegate, NSSharingServiceDelegate> {
@protected
base::WeakPtr<electron::ElectronMenuModel> model_;
base::scoped_nsobject<NSMenu> menu_;
NSMenu* __strong menu_;
NSMenuItem* __strong recentDocumentsMenuItem_;
NSMenu* __strong recentDocumentsMenuSwap_;
BOOL isMenuOpen_;
BOOL useDefaultAccelerator_;
base::OnceClosure closeCallback;
@ -52,9 +57,8 @@ class ElectronMenuModel;
// default initializer was used, then this will create the menu on first call.
- (NSMenu*)menu;
- (base::scoped_nsobject<NSMenuItem>)
makeMenuItemForIndex:(NSInteger)index
fromModel:(electron::ElectronMenuModel*)model;
- (NSMenuItem*)makeMenuItemForIndex:(NSInteger)index
fromModel:(electron::ElectronMenuModel*)model;
// Whether the menu is currently open.
- (BOOL)isMenuOpen;

View file

@ -86,13 +86,13 @@ bool MenuHasVisibleItems(const electron::ElectronMenuModel* model) {
// Called when an empty submenu is created. This inserts a menu item labeled
// "(empty)" into the submenu. Matches Windows behavior.
NSMenu* MakeEmptySubmenu() {
base::scoped_nsobject<NSMenu> submenu([[NSMenu alloc] initWithTitle:@""]);
NSMenu* submenu = [[NSMenu alloc] initWithTitle:@""];
NSString* empty_menu_title =
l10n_util::GetNSString(IDS_APP_MENU_EMPTY_SUBMENU);
[submenu addItemWithTitle:empty_menu_title action:NULL keyEquivalent:@""];
[[submenu itemAtIndex:0] setEnabled:NO];
return submenu.autorelease();
return submenu;
}
// Convert an SharingItem to an array of NSObjects.
@ -130,8 +130,7 @@ NSArray* ConvertSharingItemToNS(const SharingItem& item) {
}
+ (instancetype)weakPtrForModel:(electron::ElectronMenuModel*)model {
return [[[WeakPtrToElectronMenuModelAsNSObject alloc] initWithModel:model]
autorelease];
return [[WeakPtrToElectronMenuModelAsNSObject alloc] initWithModel:model];
}
+ (electron::ElectronMenuModel*)getFrom:(id)instance {
@ -153,12 +152,6 @@ NSArray* ConvertSharingItemToNS(const SharingItem& item) {
@end
// Menu item is located for ease of removing it from the parent owner
static base::scoped_nsobject<NSMenuItem> recentDocumentsMenuItem_;
// Submenu retained to be swapped back to |recentDocumentsMenuItem_|
static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
@implementation ElectronMenuController
- (electron::ElectronMenuModel*)model {
@ -188,7 +181,6 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
[self cancel];
model_ = nullptr;
[super dealloc];
}
- (void)setCloseCallback:(base::OnceClosure)callback {
@ -204,8 +196,8 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
std::u16string title = u"Open Recent";
NSString* openTitle = l10n_util::FixUpWindowsStyleLabel(title);
recentDocumentsMenuItem_.reset([[[[[NSApp mainMenu]
itemWithTitle:@"Electron"] submenu] itemWithTitle:openTitle] retain]);
recentDocumentsMenuItem_ = [[[[NSApp mainMenu] itemWithTitle:@"Electron"]
submenu] itemWithTitle:openTitle];
}
model_ = model->GetWeakPtr();
@ -236,7 +228,7 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
// Creates a NSMenu from the given model. If the model has submenus, this can
// be invoked recursively.
- (NSMenu*)menuFromModel:(electron::ElectronMenuModel*)model {
NSMenu* menu = [[[NSMenu alloc] initWithTitle:@""] autorelease];
NSMenu* menu = [[NSMenu alloc] initWithTitle:@""];
const int count = model->GetItemCount();
for (int index = 0; index < count; index++) {
@ -261,7 +253,7 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
- (void)moveMenuItems:(NSMenu*)source to:(NSMenu*)destination {
const NSInteger count = [source numberOfItems];
for (NSInteger index = 0; index < count; index++) {
NSMenuItem* removedItem = [[[source itemAtIndex:0] retain] autorelease];
NSMenuItem* removedItem = [source itemAtIndex:0];
[source removeItemAtIndex:0];
[destination addItem:removedItem];
}
@ -270,8 +262,7 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
// Replaces the item's submenu instance with the singleton recent documents
// menu. Previously replaced menu items will be recovered.
- (void)replaceSubmenuShowingRecentDocuments:(NSMenuItem*)item {
NSMenu* recentDocumentsMenu =
[[[recentDocumentsMenuItem_ submenu] retain] autorelease];
NSMenu* recentDocumentsMenu = [recentDocumentsMenuItem_ submenu];
// Remove menu items in recent documents back to swap menu
[self moveMenuItems:recentDocumentsMenu to:recentDocumentsMenuSwap_];
@ -279,7 +270,7 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
[recentDocumentsMenuItem_ setSubmenu:recentDocumentsMenuSwap_];
// Retain the item's submenu for a future recovery
recentDocumentsMenuSwap_.reset([[item submenu] retain]);
recentDocumentsMenuSwap_ = [item submenu];
// Repopulate with items from the submenu to be replaced
[self moveMenuItems:recentDocumentsMenuSwap_ to:recentDocumentsMenu];
@ -292,7 +283,7 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
DCHECK_EQ([item target], recentDocumentsMenu);
// Remember the new menu item that carries the recent documents menu
recentDocumentsMenuItem_.reset([item retain]);
recentDocumentsMenuItem_ = item;
}
// Fill the menu with Share Menu items.
@ -300,36 +291,33 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
NSArray* items = ConvertSharingItemToNS(item);
if ([items count] == 0)
return MakeEmptySubmenu();
base::scoped_nsobject<NSMenu> menu([[NSMenu alloc] init]);
NSMenu* menu = [[NSMenu alloc] init];
NSArray* services = [NSSharingService sharingServicesForItems:items];
for (NSSharingService* service in services)
[menu addItem:[self menuItemForService:service withItems:items]];
return menu.autorelease();
return menu;
}
// Creates a menu item that calls |service| when invoked.
- (NSMenuItem*)menuItemForService:(NSSharingService*)service
withItems:(NSArray*)items {
base::scoped_nsobject<NSMenuItem> item([[NSMenuItem alloc]
initWithTitle:service.menuItemTitle
action:@selector(performShare:)
keyEquivalent:@""]);
NSMenuItem* item = [[NSMenuItem alloc] initWithTitle:service.menuItemTitle
action:@selector(performShare:)
keyEquivalent:@""];
[item setTarget:self];
[item setImage:service.image];
[item setRepresentedObject:@{@"service" : service, @"items" : items}];
return item.autorelease();
return item;
}
- (base::scoped_nsobject<NSMenuItem>)
makeMenuItemForIndex:(NSInteger)index
fromModel:(electron::ElectronMenuModel*)model {
- (NSMenuItem*)makeMenuItemForIndex:(NSInteger)index
fromModel:(electron::ElectronMenuModel*)model {
std::u16string label16 = model->GetLabelAt(index);
NSString* label = l10n_util::FixUpWindowsStyleLabel(label16);
base::scoped_nsobject<NSMenuItem> item([[NSMenuItem alloc]
initWithTitle:label
action:@selector(itemSelected:)
keyEquivalent:@""]);
NSMenuItem* item = [[NSMenuItem alloc] initWithTitle:label
action:@selector(itemSelected:)
keyEquivalent:@""];
// If the menu item has an icon, set it.
ui::ImageModel icon = model->GetIconAt(index);
@ -348,7 +336,7 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
[item setTarget:nil];
[item setAction:nil];
NSMenu* submenu = [[[NSMenu alloc] initWithTitle:sub_label] autorelease];
NSMenu* submenu = [[NSMenu alloc] initWithTitle:sub_label];
[item setSubmenu:submenu];
[NSApp setServicesMenu:submenu];
} else if (role == u"sharemenu") {
@ -504,18 +492,18 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
- (NSMenu*)menu {
if (menu_)
return menu_.get();
return menu_;
if (model_ && model_->GetSharingItem()) {
NSMenu* menu = [self createShareMenuForItem:*model_->GetSharingItem()];
menu_.reset([menu retain]);
menu_ = menu;
} else {
menu_.reset([[NSMenu alloc] initWithTitle:@""]);
menu_ = [[NSMenu alloc] initWithTitle:@""];
if (model_)
[self populateWithModel:model_.get()];
}
[menu_ setDelegate:self];
return menu_.get();
return menu_;
}
- (BOOL)isMenuOpen {

View file

@ -14,6 +14,10 @@
#import <objc/message.h>
#import <objc/runtime.h>
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace electron {
int ScopedDisableResize::disable_resize_ = 0;
@ -248,7 +252,7 @@ void SwizzleSwipeWithEvent(NSView* view, SEL swiz_selector) {
@"NSAccessibilityReparentingCellProxy"];
NSArray* children = [super accessibilityAttributeValue:attribute];
NSMutableArray* mutableChildren = [[children mutableCopy] autorelease];
NSMutableArray* mutableChildren = [children mutableCopy];
[mutableChildren filterUsingPredicate:predicate];
return mutableChildren;

View file

@ -11,11 +11,14 @@
#include <string>
#include <vector>
#include "base/mac/scoped_nsobject.h"
#include "base/memory/raw_ptr.h"
#include "shell/browser/native_window.h"
#include "shell/common/gin_helper/persistent_dictionary.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface ElectronTouchBar : NSObject <NSScrubberDelegate,
NSScrubberDataSource,
NSScrubberFlowLayoutDelegate> {

View file

@ -55,10 +55,10 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
}
- (NSTouchBar*)touchBarFromItemIdentifiers:(NSMutableArray*)items {
base::scoped_nsobject<NSTouchBar> bar([[NSTouchBar alloc] init]);
NSTouchBar* bar = [[NSTouchBar alloc] init];
[bar setDelegate:delegate_];
[bar setDefaultItemIdentifiers:items];
return bar.autorelease();
return bar;
}
- (NSMutableArray*)identifiersFromSettings:
@ -349,15 +349,15 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
v8::HandleScope handle_scope(isolate);
gin_helper::PersistentDictionary settings = settings_[s_id];
base::scoped_nsobject<NSCustomTouchBarItem> item(
[[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]);
NSCustomTouchBarItem* item =
[[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
NSButton* button = [NSButton buttonWithTitle:@""
target:self
action:@selector(buttonAction:)];
button.tag = [id floatValue];
[item setView:button];
[self updateButton:item withSettings:settings];
return item.autorelease();
return item;
}
- (void)updateButton:(NSCustomTouchBarItem*)item
@ -410,11 +410,11 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
v8::HandleScope handle_scope(isolate);
gin_helper::PersistentDictionary settings = settings_[s_id];
base::scoped_nsobject<NSCustomTouchBarItem> item(
[[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]);
NSCustomTouchBarItem* item =
[[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
[item setView:[NSTextField labelWithString:@""]];
[self updateLabel:item withSettings:settings];
return item.autorelease();
return item;
}
- (void)updateLabel:(NSCustomTouchBarItem*)item
@ -447,20 +447,19 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
v8::HandleScope scope(isolate);
gin_helper::PersistentDictionary settings = settings_[s_id];
base::scoped_nsobject<NSColorPickerTouchBarItem> item(
[[NSColorPickerTouchBarItem alloc] initWithIdentifier:identifier]);
NSColorPickerTouchBarItem* item =
[[NSColorPickerTouchBarItem alloc] initWithIdentifier:identifier];
[item setTarget:self];
[item setAction:@selector(colorPickerAction:)];
[self updateColorPicker:item withSettings:settings];
return item.autorelease();
return item;
}
- (void)updateColorPicker:(NSColorPickerTouchBarItem*)item
withSettings:(const gin_helper::PersistentDictionary&)settings {
std::vector<std::string> colors;
if (settings.Get("availableColors", &colors) && !colors.empty()) {
NSColorList* color_list =
[[[NSColorList alloc] initWithName:@""] autorelease];
NSColorList* color_list = [[NSColorList alloc] initWithName:@""];
for (size_t i = 0; i < colors.size(); ++i) {
[color_list insertColor:[self colorFromHexColorString:colors[i]]
key:base::SysUTF8ToNSString(colors[i])
@ -485,12 +484,12 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
v8::HandleScope handle_scope(isolate);
gin_helper::PersistentDictionary settings = settings_[s_id];
base::scoped_nsobject<NSSliderTouchBarItem> item(
[[NSSliderTouchBarItem alloc] initWithIdentifier:identifier]);
NSSliderTouchBarItem* item =
[[NSSliderTouchBarItem alloc] initWithIdentifier:identifier];
[item setTarget:self];
[item setAction:@selector(sliderAction:)];
[self updateSlider:item withSettings:settings];
return item.autorelease();
return item;
}
- (void)updateSlider:(NSSliderTouchBarItem*)item
@ -521,10 +520,10 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
v8::HandleScope handle_scope(isolate);
gin_helper::PersistentDictionary settings = settings_[s_id];
base::scoped_nsobject<NSPopoverTouchBarItem> item(
[[NSPopoverTouchBarItem alloc] initWithIdentifier:identifier]);
NSPopoverTouchBarItem* item =
[[NSPopoverTouchBarItem alloc] initWithIdentifier:identifier];
[self updatePopover:item withSettings:settings];
return item.autorelease();
return item;
}
- (void)updatePopover:(NSPopoverTouchBarItem*)item
@ -613,8 +612,8 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
v8::HandleScope handle_scope(isolate);
gin_helper::PersistentDictionary settings = settings_[s_id];
base::scoped_nsobject<NSCustomTouchBarItem> item(
[[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]);
NSCustomTouchBarItem* item =
[[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
NSSegmentedControl* control = [NSSegmentedControl
segmentedControlWithLabels:[NSMutableArray array]
@ -625,7 +624,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
[item setView:control];
[self updateSegmentedControl:item withSettings:settings];
return item.autorelease();
return item;
}
- (void)updateSegmentedControl:(NSCustomTouchBarItem*)item
@ -700,11 +699,10 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
v8::HandleScope handle_scope(isolate);
gin_helper::PersistentDictionary settings = settings_[s_id];
base::scoped_nsobject<NSCustomTouchBarItem> item(
[[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]);
NSCustomTouchBarItem* item =
[[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
NSScrubber* scrubber =
[[[NSScrubber alloc] initWithFrame:NSZeroRect] autorelease];
NSScrubber* scrubber = [[NSScrubber alloc] initWithFrame:NSZeroRect];
[scrubber registerClass:[NSScrubberTextItemView class]
forItemIdentifier:TextScrubberItemIdentifier];
@ -718,7 +716,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
[item setView:scrubber];
[self updateScrubber:item withSettings:settings];
return item.autorelease();
return item;
}
- (void)updateScrubber:(NSCustomTouchBarItem*)item

View file

@ -7,7 +7,6 @@
#import <Cocoa/Cocoa.h>
#include "base/mac/scoped_nsobject.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/gfx/geometry/point.h"
@ -36,8 +35,8 @@
// Track mouse moves above window buttons.
BOOL show_on_hover_;
BOOL mouse_inside_;
base::scoped_nsobject<NSTrackingArea> tracking_area_;
base::scoped_nsobject<ButtonsAreaHoverView> hover_view_;
NSTrackingArea* __strong tracking_area_;
ButtonsAreaHoverView* __strong hover_view_;
}
- (id)initWithWindow:(NSWindow*)window;

View file

@ -70,12 +70,12 @@
// Put a transparent view above the window buttons so we can track mouse
// events when mouse enter/leave the window buttons.
if (show_on_hover_) {
hover_view_.reset([[ButtonsAreaHoverView alloc] initWithProxy:self]);
hover_view_ = [[ButtonsAreaHoverView alloc] initWithProxy:self];
[hover_view_ setFrame:[self getButtonsBounds]];
[titleBarContainer addSubview:hover_view_.get()];
[titleBarContainer addSubview:hover_view_];
} else {
[hover_view_ removeFromSuperview];
hover_view_.reset();
hover_view_ = nil;
}
[self updateButtonsVisibility];
}
@ -143,14 +143,14 @@
- (void)updateTrackingAreas {
if (tracking_area_)
[hover_view_ removeTrackingArea:tracking_area_.get()];
tracking_area_.reset([[NSTrackingArea alloc]
[hover_view_ removeTrackingArea:tracking_area_];
tracking_area_ = [[NSTrackingArea alloc]
initWithRect:NSZeroRect
options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways |
NSTrackingInVisibleRect
owner:self
userInfo:nil]);
[hover_view_ addTrackingArea:tracking_area_.get()];
userInfo:nil];
[hover_view_ addTrackingArea:tracking_area_];
}
- (void)mouseEntered:(NSEvent*)event {

View file

@ -8,10 +8,12 @@
#include "shell/browser/ui/inspectable_web_contents_view.h"
#include "base/mac/scoped_nsobject.h"
@class ElectronInspectableWebContentsView;
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace electron {
class InspectableWebContentsViewMac : public InspectableWebContentsView {
@ -34,7 +36,7 @@ class InspectableWebContentsViewMac : public InspectableWebContentsView {
void SetTitle(const std::u16string& title) override;
private:
base::scoped_nsobject<ElectronInspectableWebContentsView> view_;
ElectronInspectableWebContentsView* __strong view_;
};
} // namespace electron

View file

@ -28,7 +28,7 @@ InspectableWebContentsViewMac::~InspectableWebContentsViewMac() {
}
gfx::NativeView InspectableWebContentsViewMac::GetNativeView() const {
return view_.get();
return view_;
}
void InspectableWebContentsViewMac::ShowDevTools(bool activate) {

View file

@ -9,12 +9,15 @@
#include <string>
#include "base/mac/scoped_nsobject.h"
#include "shell/browser/ui/tray_icon.h"
@class ElectronMenuController;
@class StatusItemView;
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace electron {
class TrayIconCocoa : public TrayIcon {
@ -38,10 +41,10 @@ class TrayIconCocoa : public TrayIcon {
private:
// Electron custom view for NSStatusItem.
base::scoped_nsobject<StatusItemView> status_item_view_;
StatusItemView* __strong status_item_view_;
// Status menu shown when right-clicking the system icon.
base::scoped_nsobject<ElectronMenuController> menu_;
ElectronMenuController* __strong menu_;
base::WeakPtrFactory<TrayIconCocoa> weak_factory_{this};
};

View file

@ -23,8 +23,8 @@
raw_ptr<electron::TrayIconCocoa> trayIcon_; // weak
ElectronMenuController* menuController_; // weak
BOOL ignoreDoubleClickEvents_;
base::scoped_nsobject<NSStatusItem> statusItem_;
base::scoped_nsobject<NSTrackingArea> trackingArea_;
NSStatusItem* __strong statusItem_;
NSTrackingArea* __strong trackingArea_;
}
@end // @interface StatusItemView
@ -34,7 +34,6 @@
- (void)dealloc {
trayIcon_ = nil;
menuController_ = nil;
[super dealloc];
}
- (id)initWithIcon:(electron::TrayIconCocoa*)icon {
@ -54,7 +53,7 @@
// Create the status item.
NSStatusItem* item = [[NSStatusBar systemStatusBar]
statusItemWithLength:NSVariableStatusItemLength];
statusItem_.reset([item retain]);
statusItem_ = item;
[[statusItem_ button] addSubview:self]; // inject custom view
[self updateDimensions];
}
@ -69,12 +68,12 @@
// Use NSTrackingArea for listening to mouseEnter, mouseExit, and mouseMove
// events.
[self removeTrackingArea:trackingArea_];
trackingArea_.reset([[NSTrackingArea alloc]
trackingArea_ = [[NSTrackingArea alloc]
initWithRect:[self bounds]
options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved |
NSTrackingActiveAlways
owner:self
userInfo:nil]);
userInfo:nil];
[self addTrackingArea:trackingArea_];
}
@ -82,11 +81,11 @@
// Turn off tracking events to prevent crash.
if (trackingArea_) {
[self removeTrackingArea:trackingArea_];
trackingArea_.reset();
trackingArea_ = nil;
}
[[NSStatusBar systemStatusBar] removeStatusItem:statusItem_];
[self removeFromSuperview];
statusItem_.reset();
statusItem_ = nil;
}
- (void)setImage:(NSImage*)image {
@ -216,21 +215,13 @@
// Show a custom menu.
if (menu_model) {
base::scoped_nsobject<ElectronMenuController> menuController(
ElectronMenuController* menuController =
[[ElectronMenuController alloc] initWithModel:menu_model
useDefaultAccelerator:NO]);
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];
return;
}
@ -326,7 +317,7 @@
namespace electron {
TrayIconCocoa::TrayIconCocoa() {
status_item_view_.reset([[StatusItemView alloc] initWithIcon:this]);
status_item_view_ = [[StatusItemView alloc] initWithIcon:this];
}
TrayIconCocoa::~TrayIconCocoa() {
@ -382,12 +373,12 @@ void TrayIconCocoa::CloseContextMenu() {
void TrayIconCocoa::SetContextMenu(raw_ptr<ElectronMenuModel> menu_model) {
if (menu_model) {
// Create native menu.
menu_.reset([[ElectronMenuController alloc] initWithModel:menu_model
useDefaultAccelerator:NO]);
menu_ = [[ElectronMenuController alloc] initWithModel:menu_model
useDefaultAccelerator:NO];
} else {
menu_.reset();
menu_ = nil;
}
[status_item_view_ setMenuController:menu_.get()];
[status_item_view_ setMenuController:menu_];
}
gfx::Rect TrayIconCocoa::GetBounds() {

View file

@ -45,8 +45,11 @@ bool ShouldUseGlobalMenuBar() {
dbus::ObjectProxy* object_proxy =
bus->GetObjectProxy(DBUS_SERVICE_DBUS, dbus::ObjectPath(DBUS_PATH_DBUS));
dbus::MethodCall method_call(DBUS_INTERFACE_DBUS, "ListNames");
std::unique_ptr<dbus::Response> response(object_proxy->CallMethodAndBlock(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT));
std::unique_ptr<dbus::Response> response =
object_proxy
->CallMethodAndBlock(&method_call,
dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)
.value_or(nullptr);
if (!response) {
bus->ShutdownAndBlock();
return false;