Skip to content

Commit e757828

Browse files
committed
Add alert suppression checkbox to Restart Firefox warning
1 parent 5ca403e commit e757828

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

AppController.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ - (BOOL)showLongBlockWarningsIfNecessary {
127127
return retVal;
128128
}
129129

130-
NSString* LONG_BLOCK_SUPPRESSION_KEY = @"SuppressLongBlockWarnings";
130+
NSString* LONG_BLOCK_SUPPRESSION_KEY = @"SuppressLongBlockWarning";
131131
int LONG_BLOCK_THRESHOLD_MINS = 2880; // 2 days
132132
int FIRST_TIME_LONG_BLOCK_THRESHOLD_MINS = 480; // 8 hours
133133

SCConstants.m

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ @implementation SCConstants
6262
@"EnableErrorReporting": @([SCMiscUtilities systemThirdPartyCrashReportingEnabled]),
6363
@"ErrorReportingPromptDismissed": @NO,
6464
@"SuppressLongBlockWarning": @NO,
65+
@"SuppressRestartFirefoxWarning": @NO,
6566
@"FirstBlockStarted": @NO,
6667

6768
@"V4MigrationComplete": @NO

SCUIUtilities.m

+15-2
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,27 @@ + (BOOL)promptBrowserRestartIfNecessary {
117117
});
118118
return retVal;
119119
}
120-
120+
121+
NSString* RESTART_FF_SUPPRESSION_KEY = @"SuppressRestartFirefoxWarning";
122+
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
123+
124+
// if they don't want the warnings, they don't get the warnings
125+
if ([defaults boolForKey: RESTART_FF_SUPPRESSION_KEY]) {
126+
return NO;
127+
}
128+
121129
NSAlert* alert = [[NSAlert alloc] init];
122130
[alert setMessageText: NSLocalizedString(@"Restart Firefox", "FireFox browser restart prompt")];
123131
[alert setInformativeText:NSLocalizedString(@"SelfControl's block may not work properly in Firefox until you restart the browser. Do you want to quit Firefox now?", @"Message explaining Firefox restart requirement")];
124132
[alert addButtonWithTitle: NSLocalizedString(@"Quit Firefox", @"Button to quit Firefox")];
125133
[alert addButtonWithTitle: NSLocalizedString(@"Continue Without Restart", "Button to decline restarting Firefox")];
126-
134+
alert.showsSuppressionButton = YES;
135+
127136
NSModalResponse modalResponse = [alert runModal];
137+
if (alert.suppressionButton.state == NSControlStateValueOn) {
138+
// no more warnings, they say
139+
[defaults setBool: YES forKey: RESTART_FF_SUPPRESSION_KEY];
140+
}
128141
if (modalResponse == NSAlertFirstButtonReturn) {
129142
for (NSRunningApplication* ff in runningFF) {
130143
[ff terminate];

0 commit comments

Comments
 (0)