Skip to content

Commit 4bbf63d

Browse files
committed
Prevent the "Update available" Sparkle popup on Mac
It was shown when Brave was run as non-admin user and tried to update a system-wide installation.
1 parent 8e0a8a6 commit 4bbf63d

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

DEPS

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ deps = {
77
"vendor/boto": "https://github.com/boto/boto@f7574aa6cc2c819430c1f05e9a1a1a666ef8169b",
88
"vendor/python-patch": "https://github.com/brave/python-patch@d8880110be6554686bc08261766538c2926d4e82",
99
"vendor/omaha": "https://github.com/brave/omaha.git@baf5b9977a49db893b557c7ceca18ab414fd2a08",
10-
"vendor/sparkle": "https://github.com/brave/Sparkle.git@07933da3e178265d0f0ba86e02bbde38e701a04d",
10+
"vendor/sparkle": "https://github.com/brave/Sparkle.git@57fb153bea4c71ed10102d50e68ead89ca483b49",
1111
"vendor/bat-native-rapidjson": "https://github.com/brave-intl/bat-native-rapidjson.git@60b7e4574cebdd79f441bdd6f0f3ab469fd7e04c",
1212
"vendor/bip39wally-core-native": "https://github.com/brave-intl/bat-native-bip39wally-core.git@0d3a8713a2b388d2156fe49a70ef3f7cdb44b190",
1313
"vendor/bat-native-anonize": "https://github.com/brave-intl/bat-native-anonize.git@e3742ba3e8942eea9e4755d91532491871bd3116",

browser/mac/sparkle_glue.mm

+10-3
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,16 @@ - (void)registerWithSparkle {
190190
// Background update check interval.
191191
constexpr NSTimeInterval kBraveUpdateCheckIntervalInSec = 3 * 60 * 60;
192192
[su_updater_ setUpdateCheckInterval:kBraveUpdateCheckIntervalInSec];
193-
[su_updater_ setAutomaticallyChecksForUpdates:YES];
193+
194194
[su_updater_ setAutomaticallyDownloadsUpdates:YES];
195195

196+
// We only want to perform automatic update checks if we have write
197+
// access to the installation directory. Such access can be checked
198+
// with SUSystemUpdateInfo:systemAllowsAutomaticUpdatesForHost.
199+
// The following makes su_updater_ call this method for us because
200+
// we setAutomaticallyDownloadUpdates:YES above.
201+
if ([su_updater_ automaticallyDownloadsUpdates])
202+
[su_updater_ setAutomaticallyChecksForUpdates:YES];
196203
[self updateStatus:kAutoupdateRegistered version:nil error:nil];
197204
}
198205

@@ -229,7 +236,7 @@ - (void)checkForUpdates {
229236

230237
[self updateStatus:kAutoupdateChecking version:nil error:nil];
231238

232-
[su_updater_ checkForUpdatesInBackground];
239+
[su_updater_ checkForUpdatesInBackgroundWithoutUi];
233240
}
234241

235242
- (void)relaunch {
@@ -239,7 +246,7 @@ - (void)relaunch {
239246

240247
- (void)checkForUpdatesInBackground {
241248
DCHECK(registered_);
242-
[su_updater_ checkForUpdatesInBackground];
249+
[su_updater_ checkForUpdatesInBackgroundWithoutUi];
243250
}
244251

245252
- (void)updateStatus:(AutoupdateStatus)status

browser/mac/su_updater.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/* This Source Code Form is subject to the terms of the Mozilla Public
1+
/* Copyright 2022 The Brave Authors. All rights reserved.
2+
* This Source Code Form is subject to the terms of the Mozilla Public
23
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
34
* You can obtain one at http://mozilla.org/MPL/2.0/. */
45

@@ -16,17 +17,20 @@
1617

1718
@interface SUUpdater : NSObject
1819

19-
@property (strong) SUUpdateDriver *driver;
20+
@property(strong) SUUpdateDriver* driver; // NOLINT
2021

21-
+ (SUUpdater *)sharedUpdater;
22+
+ (SUUpdater*)sharedUpdater; // NOLINT
2223

2324
- (void)checkForUpdates:(id)sender;
2425
- (void)setDelegate:(id)delegate;
2526
- (void)setAutomaticallyChecksForUpdates:(BOOL)enable;
2627
- (void)setAutomaticallyDownloadsUpdates:(BOOL)enable;
2728
- (void)checkForUpdatesInBackground;
29+
- (void)checkForUpdatesInBackgroundWithoutUi;
2830
- (void)setUpdateCheckInterval:(NSTimeInterval)interval;
2931

32+
@property BOOL automaticallyDownloadsUpdates;
33+
3034
@end
3135

3236
#endif // BRAVE_BROWSER_MAC_SU_UPDATER_H_

0 commit comments

Comments
 (0)