[cr149] FindLastActive returning BrowserWindowInterface
This change corrects several cascading places where passing `BrowserWindowInterface` is already feasible. It also further corrects some cases `Browser*` and `Profile*` were being passed alongside each other, which is redundant. Chromium changes: https://chromium.googlesource.com/chromium/src/+/c6268a491040e14ca749fb2ba8fb131ab7512f87 commit c6268a491040e14ca749fb2ba8fb131ab7512f87 Author: Kun Wang <kunwang@microsoft.com> Date: Sun Apr 12 23:56:11 2026 -0700 [bedrock] Migrate FindLastActive Step 1 Bug:494010890 Change-Id: I52727f56f3e6172515e3f053a74cb81947c9b8f0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7743380 Reviewed-by: Tom Lukaszewicz <tluk@chromium.org> Reviewed-by: Hidehiko Abe <hidehiko@chromium.org> Commit-Queue: Kun Wang <kunwang@microsoft.com> Reviewed-by: Qikai Zhong <qikaizhong@microsoft.com> Cr-Commit-Position: refs/heads/main@{#1613517}
This commit is contained in:
@@ -275,9 +275,9 @@ IN_PROC_BROWSER_TEST_F(BraveAppControllerBrowserTest, TorItemEnabled) {
|
||||
[ac executeCommand:tor_menu withProfile:browser()->profile()];
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
Browser* tor_window = chrome::FindLastActive();
|
||||
BrowserWindowInterface* tor_window = chrome::FindLastActive();
|
||||
EXPECT_TRUE(tor_window);
|
||||
EXPECT_TRUE(tor_window->profile()->IsTor());
|
||||
EXPECT_TRUE(tor_window->GetProfile()->IsTor());
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(BraveAppControllerBrowserTest,
|
||||
|
||||
@@ -143,18 +143,17 @@ void ChromeBrowserMainParts::PostBrowserStart() {
|
||||
#endif
|
||||
|
||||
#if !BUILDFLAG(IS_ANDROID)
|
||||
Browser* browser = chrome::FindLastActive();
|
||||
BrowserWindowInterface* browser = chrome::FindLastActive();
|
||||
content::WebContents* active_web_contents = nullptr;
|
||||
|
||||
if (browser) {
|
||||
active_web_contents = browser->tab_strip_model()->GetActiveWebContents();
|
||||
active_web_contents = browser->GetTabStripModel()->GetActiveWebContents();
|
||||
|
||||
if (active_web_contents) {
|
||||
Profile* profile =
|
||||
Profile::FromBrowserContext(active_web_contents->GetBrowserContext());
|
||||
Profile* profile = browser->GetProfile();
|
||||
infobars::ContentInfoBarManager* infobar_manager =
|
||||
infobars::ContentInfoBarManager::FromWebContents(active_web_contents);
|
||||
if (profile && infobar_manager) {
|
||||
if (infobar_manager) {
|
||||
BraveConfirmP3AInfoBarDelegate::Create(
|
||||
infobar_manager, g_browser_process->local_state());
|
||||
|
||||
|
||||
@@ -39,8 +39,9 @@ bool IsAlreadyRegistered(ComponentUpdateService* cus) {
|
||||
}
|
||||
#if !BUILDFLAG(IS_LINUX)
|
||||
content::WebContents* GetActiveWebContents() {
|
||||
if (Browser* browser = chrome::FindLastActive())
|
||||
return browser->tab_strip_model()->GetActiveWebContents();
|
||||
if (BrowserWindowInterface* browser = chrome::FindLastActive()) {
|
||||
return browser->GetTabStripModel()->GetActiveWebContents();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,8 @@ void SkipDNSDialog(PrefService* prefs, bool checked) {
|
||||
|
||||
gfx::NativeWindow GetAnchorBrowserWindow() {
|
||||
auto* browser = chrome::FindLastActive();
|
||||
return browser ? browser->window()->GetNativeWindow() : gfx::NativeWindow();
|
||||
return browser ? browser->GetWindow()->GetNativeWindow()
|
||||
: gfx::NativeWindow();
|
||||
}
|
||||
|
||||
bool AreConfigsEqual(SecureDnsConfig& one, SecureDnsConfig& two) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "base/notreached.h"
|
||||
#include "brave/browser/brave_wallet/brave_wallet_tab_helper.h"
|
||||
#include "brave/browser/ui/brave_pages.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
#include "chrome/browser/ui/browser_finder.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
|
||||
|
||||
@@ -44,8 +44,9 @@ content::WebContents* GetActiveWebContents() {
|
||||
return g_web_contents_for_testing;
|
||||
}
|
||||
|
||||
Browser* browser = chrome::FindLastActive();
|
||||
return browser ? browser->tab_strip_model()->GetActiveWebContents() : nullptr;
|
||||
BrowserWindowInterface* browser = chrome::FindLastActive();
|
||||
return browser ? browser->GetTabStripModel()->GetActiveWebContents()
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
void ClearWalletStoragePartition(content::BrowserContext* context,
|
||||
|
||||
@@ -101,8 +101,7 @@ void CosmeticFiltersTabHelper::ManageCustomFilters() {
|
||||
if (!browser_window_interface) {
|
||||
return;
|
||||
}
|
||||
brave::ShowBraveAdblock(
|
||||
browser_window_interface->GetBrowserForMigrationOnly());
|
||||
brave::ShowBraveAdblock(browser_window_interface);
|
||||
#else // !BUILDFLAG(IS_ANDROID)
|
||||
ShowCustomFilterSettings();
|
||||
#endif // !BUILDFLAG(IS_ANDROID)
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/sync/sync_service_factory.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
#include "chrome/browser/ui/browser_window/public/browser_window_interface.h"
|
||||
#include "components/infobars/content/content_infobar_manager.h"
|
||||
#include "components/infobars/core/infobar.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
@@ -40,9 +41,9 @@ BraveSyncServiceImpl* GetSyncService(Profile* profile) {
|
||||
// static
|
||||
void SyncCannotRunInfoBarDelegate::Create(
|
||||
infobars::ContentInfoBarManager* infobar_manager,
|
||||
Profile* profile,
|
||||
Browser* browser) {
|
||||
BraveSyncServiceImpl* brave_sync_service = GetSyncService(profile);
|
||||
BrowserWindowInterface* browser) {
|
||||
BraveSyncServiceImpl* brave_sync_service =
|
||||
GetSyncService(browser->GetProfile());
|
||||
if (!brave_sync_service || !brave_sync_service->has_encryptor()) {
|
||||
return;
|
||||
}
|
||||
@@ -53,13 +54,13 @@ void SyncCannotRunInfoBarDelegate::Create(
|
||||
|
||||
infobar_manager->AddInfoBar(
|
||||
CreateConfirmInfoBar(std::unique_ptr<ConfirmInfoBarDelegate>(
|
||||
new SyncCannotRunInfoBarDelegate(browser, profile))));
|
||||
new SyncCannotRunInfoBarDelegate(browser))));
|
||||
}
|
||||
|
||||
// Start class impl
|
||||
SyncCannotRunInfoBarDelegate::SyncCannotRunInfoBarDelegate(Browser* browser,
|
||||
Profile* profile)
|
||||
: profile_(profile), browser_(browser) {}
|
||||
SyncCannotRunInfoBarDelegate::SyncCannotRunInfoBarDelegate(
|
||||
BrowserWindowInterface* browser)
|
||||
: browser_(browser) {}
|
||||
|
||||
SyncCannotRunInfoBarDelegate::~SyncCannotRunInfoBarDelegate() = default;
|
||||
|
||||
@@ -110,7 +111,7 @@ bool SyncCannotRunInfoBarDelegate::Accept() {
|
||||
|
||||
bool SyncCannotRunInfoBarDelegate::Cancel() {
|
||||
// "Don't show again" button
|
||||
brave_sync::Prefs brave_sync_prefs(profile_->GetPrefs());
|
||||
brave_sync::Prefs brave_sync_prefs(browser_->GetProfile()->GetPrefs());
|
||||
brave_sync_prefs.DismissFailedDecryptSeedNotice();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
|
||||
#include "components/infobars/core/confirm_infobar_delegate.h"
|
||||
|
||||
class Browser;
|
||||
class Profile;
|
||||
|
||||
namespace brave_sync {
|
||||
class Prefs;
|
||||
} // namespace brave_sync
|
||||
@@ -19,6 +16,8 @@ namespace infobars {
|
||||
class ContentInfoBarManager;
|
||||
} // namespace infobars
|
||||
|
||||
class BrowserWindowInterface;
|
||||
|
||||
class SyncCannotRunInfoBarDelegate : public ConfirmInfoBarDelegate {
|
||||
public:
|
||||
SyncCannotRunInfoBarDelegate(const SyncCannotRunInfoBarDelegate&) = delete;
|
||||
@@ -26,11 +25,10 @@ class SyncCannotRunInfoBarDelegate : public ConfirmInfoBarDelegate {
|
||||
delete;
|
||||
|
||||
static void Create(infobars::ContentInfoBarManager* infobar_manager,
|
||||
Profile* profile,
|
||||
Browser* browser);
|
||||
BrowserWindowInterface* browser);
|
||||
|
||||
private:
|
||||
explicit SyncCannotRunInfoBarDelegate(Browser* browser, Profile* profile);
|
||||
explicit SyncCannotRunInfoBarDelegate(BrowserWindowInterface* browser);
|
||||
~SyncCannotRunInfoBarDelegate() override;
|
||||
|
||||
// ConfirmInfoBarDelegate overrides
|
||||
@@ -44,8 +42,7 @@ class SyncCannotRunInfoBarDelegate : public ConfirmInfoBarDelegate {
|
||||
bool Accept() override;
|
||||
bool Cancel() override;
|
||||
|
||||
raw_ptr<Profile> profile_ = nullptr;
|
||||
raw_ptr<Browser> browser_ = nullptr;
|
||||
raw_ptr<BrowserWindowInterface> browser_ = nullptr;
|
||||
};
|
||||
|
||||
#endif // BRAVE_BROWSER_INFOBARS_SYNC_CANNOT_RUN_INFOBAR_DELEGATE_H_
|
||||
|
||||
@@ -78,16 +78,15 @@ void BraveSyncAlertsService::OnSyncShutdown(SyncService* sync_service) {
|
||||
|
||||
void BraveSyncAlertsService::ShowSyncCannotRunInfobar() {
|
||||
#if !BUILDFLAG(IS_ANDROID)
|
||||
Browser* browser = chrome::FindLastActive();
|
||||
BrowserWindowInterface* browser = chrome::FindLastActive();
|
||||
if (browser) {
|
||||
content::WebContents* active_web_contents =
|
||||
browser->tab_strip_model()->GetActiveWebContents();
|
||||
browser->GetTabStripModel()->GetActiveWebContents();
|
||||
if (active_web_contents) {
|
||||
infobars::ContentInfoBarManager* infobar_manager =
|
||||
infobars::ContentInfoBarManager::FromWebContents(active_web_contents);
|
||||
if (infobar_manager) {
|
||||
SyncCannotRunInfoBarDelegate::Create(infobar_manager, profile_,
|
||||
browser);
|
||||
SyncCannotRunInfoBarDelegate::Create(infobar_manager, browser);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,10 +98,10 @@ void BraveSyncAlertsService::ShowInfobar() {
|
||||
JNIEnv* env = base::android::AttachCurrentThread();
|
||||
Java_BraveSyncAccountDeletedInformer_show(env);
|
||||
#else
|
||||
Browser* browser = chrome::FindLastActive();
|
||||
BrowserWindowInterface* browser = chrome::FindLastActive();
|
||||
if (browser) {
|
||||
content::WebContents* active_web_contents =
|
||||
browser->tab_strip_model()->GetActiveWebContents();
|
||||
browser->GetTabStripModel()->GetActiveWebContents();
|
||||
if (active_web_contents) {
|
||||
BraveSyncAccountDeletedInfoBarDelegate::Create(active_web_contents,
|
||||
profile_);
|
||||
|
||||
+15
-19
@@ -12,6 +12,7 @@
|
||||
#include "brave/components/constants/webui_url_constants.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
#include "chrome/browser/ui/browser_navigator_params.h"
|
||||
#include "chrome/browser/ui/browser_window/public/browser_window_interface.h"
|
||||
#include "chrome/browser/ui/chrome_pages.h"
|
||||
#include "chrome/browser/ui/singleton_tabs.h"
|
||||
#include "chrome/common/webui_url_constants.h"
|
||||
@@ -27,36 +28,36 @@
|
||||
|
||||
namespace brave {
|
||||
|
||||
void ShowBraveRewards(Browser* browser) {
|
||||
void ShowBraveRewards(BrowserWindowInterface* browser) {
|
||||
ShowSingletonTabOverwritingNTP(browser, GURL(kRewardsPageURL));
|
||||
}
|
||||
|
||||
void ShowBraveAdblock(Browser* browser) {
|
||||
void ShowBraveAdblock(BrowserWindowInterface* browser) {
|
||||
ShowSingletonTabOverwritingNTP(browser, GURL(kBraveUIAdblockURL));
|
||||
}
|
||||
|
||||
void ShowSync(Browser* browser) {
|
||||
void ShowSync(BrowserWindowInterface* browser) {
|
||||
ShowSingletonTabOverwritingNTP(
|
||||
browser, chrome::GetSettingsUrl(chrome::kSyncSetupSubPage));
|
||||
}
|
||||
|
||||
void ShowBraveNewsConfigure(Browser* browser) {
|
||||
void ShowBraveNewsConfigure(BrowserWindowInterface* browser) {
|
||||
ShowSingletonTabOverwritingNTP(
|
||||
browser, GURL("brave://newtab/?openSettings=BraveNews"));
|
||||
}
|
||||
|
||||
void ShowShortcutsPage(Browser* browser) {
|
||||
void ShowShortcutsPage(BrowserWindowInterface* browser) {
|
||||
ShowSingletonTabOverwritingNTP(browser, GURL(kShortcutsURL));
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_BRAVE_TALK)
|
||||
void ShowBraveTalk(Browser* browser) {
|
||||
void ShowBraveTalk(BrowserWindowInterface* browser) {
|
||||
ShowSingletonTabOverwritingNTP(browser, GURL(sidebar::kBraveTalkURL));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(ENABLE_AI_CHAT)
|
||||
void ShowFullpageChat(Browser* browser) {
|
||||
void ShowFullpageChat(BrowserWindowInterface* browser) {
|
||||
if (!ai_chat::features::IsAIChatHistoryEnabled()) {
|
||||
return;
|
||||
}
|
||||
@@ -64,9 +65,9 @@ void ShowFullpageChat(Browser* browser) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void ShowWebcompatReporter(Browser* browser) {
|
||||
void ShowWebcompatReporter(BrowserWindowInterface* browser) {
|
||||
content::WebContents* web_contents =
|
||||
browser->tab_strip_model()->GetActiveWebContents();
|
||||
browser->GetTabStripModel()->GetActiveWebContents();
|
||||
if (!web_contents) {
|
||||
return;
|
||||
}
|
||||
@@ -76,31 +77,26 @@ void ShowWebcompatReporter(Browser* browser) {
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_BRAVE_WALLET)
|
||||
void ShowBraveWallet(Browser* browser) {
|
||||
void ShowBraveWallet(BrowserWindowInterface* browser) {
|
||||
ShowSingletonTabOverwritingNTP(browser, GURL(kBraveUIWalletURL));
|
||||
}
|
||||
|
||||
void ShowBraveWalletOnboarding(Browser* browser) {
|
||||
void ShowBraveWalletOnboarding(BrowserWindowInterface* browser) {
|
||||
ShowSingletonTabOverwritingNTP(browser, GURL(kBraveUIWalletOnboardingURL));
|
||||
}
|
||||
|
||||
void ShowBraveWalletTxNotificationUrl(BrowserWindowInterface* browser,
|
||||
GURL url) {
|
||||
if (url.GetWithEmptyPath() != GURL(kBraveUIWalletURL)) {
|
||||
return;
|
||||
}
|
||||
ShowSingletonTabOverwritingNTP(browser, url);
|
||||
}
|
||||
|
||||
void ShowBraveWalletAccountCreation(Browser* browser,
|
||||
std::string_view coin_name) {
|
||||
ShowSingletonTabOverwritingNTP(
|
||||
browser,
|
||||
GURL(base::StrCat({kBraveUIWalletAccountCreationURL, coin_name})));
|
||||
}
|
||||
void ShowBraveWalletAccountCreation(BrowserWindowInterface* browser,
|
||||
std::string_view coin_name) {}
|
||||
#endif
|
||||
|
||||
void ShowAppsPage(Browser* browser) {
|
||||
void ShowAppsPage(BrowserWindowInterface* browser) {
|
||||
ShowSingletonTabOverwritingNTP(browser, GURL(chrome::kChromeUIAppsURL));
|
||||
}
|
||||
|
||||
|
||||
+13
-13
@@ -18,29 +18,29 @@ class GURL;
|
||||
|
||||
namespace brave {
|
||||
|
||||
void ShowBraveAdblock(Browser* browser);
|
||||
void ShowWebcompatReporter(Browser* browser);
|
||||
void ShowBraveRewards(Browser* browser);
|
||||
void ShowBraveAdblock(BrowserWindowInterface* browser);
|
||||
void ShowWebcompatReporter(BrowserWindowInterface* browser);
|
||||
void ShowBraveRewards(BrowserWindowInterface* browser);
|
||||
#if BUILDFLAG(ENABLE_BRAVE_WALLET)
|
||||
void ShowBraveWallet(Browser* browser);
|
||||
void ShowBraveWalletOnboarding(Browser* browser);
|
||||
void ShowBraveWallet(BrowserWindowInterface* browser);
|
||||
void ShowBraveWalletOnboarding(BrowserWindowInterface* browser);
|
||||
void ShowBraveWalletTxNotificationUrl(BrowserWindowInterface* browser,
|
||||
GURL url);
|
||||
void ShowBraveWalletAccountCreation(Browser* browser,
|
||||
void ShowBraveWalletAccountCreation(BrowserWindowInterface* browser,
|
||||
std::string_view coin_name);
|
||||
#endif
|
||||
void ShowExtensionSettings(Browser* browser);
|
||||
void ShowSync(Browser* browser);
|
||||
void ShowBraveNewsConfigure(Browser* browser);
|
||||
void ShowShortcutsPage(Browser* browser);
|
||||
void ShowExtensionSettings(BrowserWindowInterface* browser);
|
||||
void ShowSync(BrowserWindowInterface* browser);
|
||||
void ShowBraveNewsConfigure(BrowserWindowInterface* browser);
|
||||
void ShowShortcutsPage(BrowserWindowInterface* browser);
|
||||
#if BUILDFLAG(ENABLE_BRAVE_TALK)
|
||||
void ShowBraveTalk(Browser* browser);
|
||||
void ShowBraveTalk(BrowserWindowInterface* browser);
|
||||
#endif
|
||||
#if BUILDFLAG(ENABLE_AI_CHAT)
|
||||
void ShowFullpageChat(Browser* browser);
|
||||
void ShowFullpageChat(BrowserWindowInterface* browser);
|
||||
#endif
|
||||
|
||||
void ShowAppsPage(Browser* browser);
|
||||
void ShowAppsPage(BrowserWindowInterface* browser);
|
||||
|
||||
} // namespace brave
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
#include "chrome/browser/ui/browser_navigator_params.h"
|
||||
#include "chrome/browser/ui/browser_tabstrip.h"
|
||||
#include "chrome/browser/ui/browser_window/public/browser_window_features.h"
|
||||
#include "chrome/browser/ui/browser_window/public/browser_window_interface.h"
|
||||
#include "chrome/browser/ui/browser_window/public/global_browser_collection.h"
|
||||
#include "chrome/browser/ui/profiles/profile_picker.h"
|
||||
#include "chrome/browser/ui/tabs/features.h"
|
||||
@@ -347,12 +348,12 @@ void CloseWalletBubble(Browser* browser) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void CopySanitizedURL(Browser* browser, const GURL& url) {
|
||||
if (!browser || !browser->profile()) {
|
||||
void CopySanitizedURL(BrowserWindowInterface* browser, const GURL& url) {
|
||||
if (!browser || !browser->GetProfile()) {
|
||||
return;
|
||||
}
|
||||
GURL sanitized_url = brave::URLSanitizerServiceFactory::GetForBrowserContext(
|
||||
browser->profile())
|
||||
browser->GetProfile())
|
||||
->SanitizeURL(url);
|
||||
|
||||
ui::ScopedClipboardWriter scw(ui::ClipboardBuffer::kCopyPaste);
|
||||
|
||||
@@ -29,6 +29,7 @@ class ActionItem;
|
||||
#endif
|
||||
|
||||
class Browser;
|
||||
class BrowserWindowInterface;
|
||||
class Profile;
|
||||
|
||||
namespace brave {
|
||||
@@ -55,7 +56,7 @@ void ToggleBraveVPNButton(Browser* browser);
|
||||
void ToggleBraveVPNTrayIcon();
|
||||
void OpenBraveVPNUrls(Browser* browser, int command_id);
|
||||
// Copies an url sanitized by URLSanitizerService.
|
||||
void CopySanitizedURL(Browser* browser, const GURL& url);
|
||||
void CopySanitizedURL(BrowserWindowInterface* browser, const GURL& url);
|
||||
// Copies an url cleared through:
|
||||
// - Debouncer (potentially debouncing many levels)
|
||||
// - Query filter
|
||||
|
||||
@@ -39,8 +39,9 @@ constexpr int kDialogWidth = 600;
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
void BraveVpnDnsSettingsNotificiationDialogView::Show(Browser* browser) {
|
||||
auto* prefs = browser->profile()->GetPrefs();
|
||||
void BraveVpnDnsSettingsNotificiationDialogView::Show(
|
||||
BrowserWindowInterface* browser) {
|
||||
auto* prefs = browser->GetProfile()->GetPrefs();
|
||||
if (!prefs->GetBoolean(prefs::kBraveVPNShowNotificationDialog))
|
||||
return;
|
||||
// The dialog eats mouse events which results in the close button
|
||||
@@ -53,13 +54,13 @@ void BraveVpnDnsSettingsNotificiationDialogView::Show(Browser* browser) {
|
||||
|
||||
constrained_window::CreateBrowserModalDialogViews(
|
||||
new BraveVpnDnsSettingsNotificiationDialogView(browser),
|
||||
browser->window()->GetNativeWindow())
|
||||
browser->GetWindow()->GetNativeWindow())
|
||||
->Show();
|
||||
}
|
||||
|
||||
BraveVpnDnsSettingsNotificiationDialogView::
|
||||
BraveVpnDnsSettingsNotificiationDialogView(Browser* browser)
|
||||
: browser_(browser), prefs_(browser->profile()->GetPrefs()) {
|
||||
BraveVpnDnsSettingsNotificiationDialogView(BrowserWindowInterface* browser)
|
||||
: browser_(browser), prefs_(browser->GetProfile()->GetPrefs()) {
|
||||
SetLayoutManager(std::make_unique<views::BoxLayout>(
|
||||
views::BoxLayout::Orientation::kVertical,
|
||||
gfx::Insets::TLBR(kTopPadding, kPadding, kBottomPadding, kPadding),
|
||||
@@ -117,7 +118,8 @@ BraveVpnDnsSettingsNotificiationDialogView::
|
||||
~BraveVpnDnsSettingsNotificiationDialogView() = default;
|
||||
|
||||
void BraveVpnDnsSettingsNotificiationDialogView::OnLearnMoreLinkClicked() {
|
||||
chrome::AddSelectedTabWithURL(browser_, GURL(kBraveVPNLearnMoreURL),
|
||||
chrome::AddSelectedTabWithURL(browser_->GetBrowserForMigrationOnly(),
|
||||
GURL(kBraveVPNLearnMoreURL),
|
||||
ui::PAGE_TRANSITION_AUTO_TOPLEVEL);
|
||||
AcceptDialog();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "ui/views/window/dialog_delegate.h"
|
||||
|
||||
class Browser;
|
||||
class BrowserWindowInterface;
|
||||
class PrefService;
|
||||
|
||||
namespace views {
|
||||
@@ -22,8 +22,7 @@ class BraveVpnDnsSettingsNotificiationDialogView
|
||||
METADATA_HEADER(BraveVpnDnsSettingsNotificiationDialogView,
|
||||
views::DialogDelegateView)
|
||||
public:
|
||||
|
||||
static void Show(Browser* browser);
|
||||
static void Show(BrowserWindowInterface* browser);
|
||||
|
||||
BraveVpnDnsSettingsNotificiationDialogView(
|
||||
const BraveVpnDnsSettingsNotificiationDialogView&) = delete;
|
||||
@@ -31,7 +30,8 @@ class BraveVpnDnsSettingsNotificiationDialogView
|
||||
const BraveVpnDnsSettingsNotificiationDialogView&) = delete;
|
||||
|
||||
private:
|
||||
explicit BraveVpnDnsSettingsNotificiationDialogView(Browser* browser);
|
||||
explicit BraveVpnDnsSettingsNotificiationDialogView(
|
||||
BrowserWindowInterface* browser);
|
||||
~BraveVpnDnsSettingsNotificiationDialogView() override;
|
||||
|
||||
void OnAccept();
|
||||
@@ -45,7 +45,7 @@ class BraveVpnDnsSettingsNotificiationDialogView
|
||||
bool ShouldShowWindowTitle() const override;
|
||||
|
||||
bool close_window_ = true;
|
||||
raw_ptr<Browser> browser_ = nullptr;
|
||||
raw_ptr<BrowserWindowInterface> browser_ = nullptr;
|
||||
raw_ptr<PrefService> prefs_ = nullptr;
|
||||
raw_ptr<views::Checkbox> dont_ask_again_checkbox_ = nullptr;
|
||||
};
|
||||
|
||||
@@ -46,20 +46,20 @@ constexpr int kDialogWidth = 600;
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
void BraveVpnFallbackDialogView::Show(Browser* browser) {
|
||||
auto* prefs = browser->profile()->GetPrefs();
|
||||
void BraveVpnFallbackDialogView::Show(BrowserWindowInterface* browser) {
|
||||
auto* prefs = browser->GetProfile()->GetPrefs();
|
||||
if (!prefs->GetBoolean(prefs::kBraveVPNWireguardFallbackDialog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
constrained_window::CreateBrowserModalDialogViews(
|
||||
new BraveVpnFallbackDialogView(browser),
|
||||
browser->window()->GetNativeWindow())
|
||||
new BraveVpnFallbackDialogView(prefs),
|
||||
browser->GetWindow()->GetNativeWindow())
|
||||
->Show();
|
||||
}
|
||||
|
||||
BraveVpnFallbackDialogView::BraveVpnFallbackDialogView(Browser* browser)
|
||||
: browser_(browser), prefs_(browser->profile()->GetPrefs()) {
|
||||
BraveVpnFallbackDialogView::BraveVpnFallbackDialogView(PrefService* prefs)
|
||||
: prefs_(prefs) {
|
||||
SetLayoutManager(std::make_unique<views::BoxLayout>(
|
||||
views::BoxLayout::Orientation::kVertical,
|
||||
gfx::Insets::TLBR(kTopPadding, kPadding, kBottomPadding, kPadding),
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "ui/views/window/dialog_delegate.h"
|
||||
|
||||
class Browser;
|
||||
class BrowserWindowInterface;
|
||||
class PrefService;
|
||||
|
||||
namespace views {
|
||||
@@ -20,15 +20,14 @@ namespace brave_vpn {
|
||||
class BraveVpnFallbackDialogView : public views::DialogDelegateView {
|
||||
METADATA_HEADER(BraveVpnFallbackDialogView, views::DialogDelegateView)
|
||||
public:
|
||||
|
||||
static void Show(Browser* browser);
|
||||
static void Show(BrowserWindowInterface* browser);
|
||||
|
||||
BraveVpnFallbackDialogView(const BraveVpnFallbackDialogView&) = delete;
|
||||
BraveVpnFallbackDialogView& operator=(const BraveVpnFallbackDialogView&) =
|
||||
delete;
|
||||
|
||||
private:
|
||||
explicit BraveVpnFallbackDialogView(Browser* browser);
|
||||
explicit BraveVpnFallbackDialogView(PrefService* prefs);
|
||||
~BraveVpnFallbackDialogView() override;
|
||||
|
||||
void OnAccept();
|
||||
@@ -39,7 +38,6 @@ class BraveVpnFallbackDialogView : public views::DialogDelegateView {
|
||||
bool ShouldShowCloseButton() const override;
|
||||
bool ShouldShowWindowTitle() const override;
|
||||
|
||||
raw_ptr<Browser> browser_ = nullptr;
|
||||
raw_ptr<PrefService> prefs_ = nullptr;
|
||||
raw_ptr<views::Checkbox> dont_ask_again_checkbox_ = nullptr;
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@ void ShowObsoleteSystemConfirmDialog(base::OnceCallback<void(bool)> callback) {
|
||||
if (auto* browser = chrome::FindLastActive()) {
|
||||
constrained_window::CreateBrowserModalDialogViews(
|
||||
new ObsoleteSystemConfirmDialogView(std::move(callback)),
|
||||
browser->window()->GetNativeWindow())
|
||||
browser->GetWindow()->GetNativeWindow())
|
||||
->Show();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user