Skip to content

Commit c4c1fde

Browse files
authored
Fix crash when "New Private Window with Tor" is selected without a window open. (uplift to 1.65.x) (#23172)
Uplift of #23126 (squashed) to release
1 parent 900fe02 commit c4c1fde

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

browser/brave_app_controller_mac.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ - (void)executeCommand:(id)sender withProfile:(Profile*)profile {
201201

202202
#if BUILDFLAG(ENABLE_TOR)
203203
if (tag == IDC_NEW_OFFTHERECORD_WINDOW_TOR) {
204-
brave::NewOffTheRecordWindowTor([self getBrowser]);
204+
brave::NewOffTheRecordWindowTor(profile);
205205
return;
206206
}
207207
#endif // BUILDFLAG(ENABLE_TOR)

browser/ui/browser_commands.cc

+8-3
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,17 @@ bool CanTakeTabs(const Browser* from, const Browser* to) {
110110

111111
void NewOffTheRecordWindowTor(Browser* browser) {
112112
CHECK(browser);
113-
if (browser->profile()->IsTor()) {
114-
chrome::OpenEmptyWindow(browser->profile());
113+
NewOffTheRecordWindowTor(browser->profile());
114+
}
115+
116+
void NewOffTheRecordWindowTor(Profile* profile) {
117+
CHECK(profile);
118+
if (profile->IsTor()) {
119+
chrome::OpenEmptyWindow(profile);
115120
return;
116121
}
117122

118-
TorProfileManager::SwitchToTorProfile(browser->profile());
123+
TorProfileManager::SwitchToTorProfile(profile);
119124
}
120125

121126
void NewTorConnectionForSite(Browser* browser) {

browser/ui/browser_commands.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@
1111

1212
class Browser;
1313
class GURL;
14+
class Profile;
1415

1516
namespace brave {
1617

1718
bool HasSelectedURL(Browser* browser);
1819
void CleanAndCopySelectedURL(Browser* browser);
19-
void NewOffTheRecordWindowTor(Browser*);
20+
void NewOffTheRecordWindowTor(Browser* browser);
21+
void NewOffTheRecordWindowTor(Profile* profile);
22+
2023
void NewTorConnectionForSite(Browser*);
2124
void ShowWalletBubble(Browser* browser);
2225
void ShowApproveWalletBubble(Browser* browser);

0 commit comments

Comments
 (0)