File tree 3 files changed +21
-2
lines changed 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 17
17
base::scoped_nsobject<NSUserActivity > currentActivity_;
18
18
NSCondition * handoffLock_;
19
19
BOOL updateReceived_;
20
+ BOOL userStoppedShutdown_;
20
21
base::Callback<bool ()> shouldShutdown_;
21
22
}
22
23
25
26
- (void )setShutdownHandler : (base::Callback<bool()>)handler ;
26
27
- (void )registerURLHandler ;
27
28
29
+ // Called when macOS itself is shutting down.
30
+ - (void )willPowerOff : (NSNotification *)notify ;
31
+
28
32
// CrAppProtocol:
29
33
- (BOOL )isHandlingSendEvent ;
30
34
Original file line number Diff line number Diff line change @@ -41,9 +41,14 @@ + (AtomApplication*)sharedApplication {
41
41
return (AtomApplication*)[super sharedApplication ];
42
42
}
43
43
44
+ - (void )willPowerOff : (NSNotification *)notify {
45
+ userStoppedShutdown_ = shouldShutdown_ && !shouldShutdown_.Run ();
46
+ }
47
+
44
48
- (void )terminate : (id )sender {
45
- if (shouldShutdown_ && !shouldShutdown_.Run ())
46
- return ; // User will call Quit later.
49
+ // User will call Quit later.
50
+ if (userStoppedShutdown_)
51
+ return ;
47
52
48
53
// We simply try to close the browser, which in turn will try to close the
49
54
// windows. Termination can proceed if all windows are closed or window close
Original file line number Diff line number Diff line change @@ -48,12 +48,22 @@ - (void)setApplicationDockMenu:(electron::ElectronMenuModel*)model {
48
48
useDefaultAccelerator: NO ]);
49
49
}
50
50
51
+ - (void )willPowerOff : (NSNotification *)notify {
52
+ [[AtomApplication sharedApplication ] willPowerOff: notify];
53
+ }
54
+
51
55
- (void )applicationWillFinishLaunching : (NSNotification *)notify {
52
56
// Don't add the "Enter Full Screen" menu item automatically.
53
57
[[NSUserDefaults standardUserDefaults ]
54
58
setBool: NO
55
59
forKey: @" NSFullScreenMenuItemEverywhere" ];
56
60
61
+ [[[NSWorkspace sharedWorkspace ] notificationCenter ]
62
+ addObserver: self
63
+ selector: @selector (willPowerOff: )
64
+ name: NSWorkspaceWillPowerOffNotification
65
+ object: nil ];
66
+
57
67
electron::Browser::Get ()->WillFinishLaunching ();
58
68
}
59
69
You can’t perform that action at this time.
0 commit comments