0

Make the default constructors for gfx::NativeView and gfx::NativeWidget on the Mac be explicit

Bug: 40264240
Change-Id: I1195fa122c59b4929aca39640a304f226f9738e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6367736
Commit-Queue: Avi Drissman <avi@chromium.org>
Owners-Override: Avi Drissman <avi@chromium.org>
Reviewed-by: Leonard Grey <lgrey@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1435683}
This commit is contained in:
Avi Drissman
2025-03-20 14:14:44 -07:00
committed by Chromium LUCI CQ
parent 06fac88b1d
commit 581b366a50
90 changed files with 277 additions and 208 deletions
chrome
browser
devtools
extensions
importer
media
printing
search_engine_choice
supervised_user
ui
ask_google_for_suggestions_dialog_browsertest.cc
autofill
bookmarks
chrome_select_file_policy_unittest.cc
extensions
profiles
startup
tabs
toolbar
views
web_applications
webui
test
components/constrained_window
content/browser
extensions
headless/lib/browser
ui

@ -16,6 +16,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/base/mojom/ui_base_types.mojom-shared.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/layout_provider.h"
@ -120,7 +121,7 @@ bool ProcessSharingInfobarDelegate::Accept() {
views::DialogDelegate::CreateDialogWidget(
std::move(delegate), inspected_web_contents_->GetTopLevelNativeWindow(),
nullptr)
gfx::NativeView())
->Show();
return ConfirmInfoBarDelegate::Accept();

@ -113,6 +113,7 @@
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/re2/src/re2/re2.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/shell_dialogs/selected_file_info.h"
#include "url/gurl.h"
#include "url/origin.h"
@ -1386,7 +1387,7 @@ DeveloperPrivateRemoveMultipleExtensionsFunction::Run() {
gfx::NativeWindow parent;
if (!GetSenderWebContents()) {
CHECK_IS_TEST();
parent = nullptr;
parent = gfx::NativeWindow();
} else {
parent = chrome::FindBrowserWithTab(GetSenderWebContents())
->window()

@ -26,6 +26,7 @@
#include "extensions/browser/extensions_browser_client.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h"
#include "ui/gfx/native_widget_types.h"
#if BUILDFLAG(IS_CHROMEOS)
#include "base/strings/string_split.h"
@ -244,7 +245,8 @@ void ChromeFeedbackPrivateDelegate::NotifyFeedbackDelayed() const {
// Show a message box to indicate that sending the feedback has been delayed
// because the user is offline.
chrome::ShowWarningMessageBox(
nullptr, l10n_util::GetStringUTF16(IDS_FEEDBACK_OFFLINE_DIALOG_TITLE),
gfx::NativeWindow(),
l10n_util::GetStringUTF16(IDS_FEEDBACK_OFFLINE_DIALOG_TITLE),
l10n_util::GetStringUTF16(IDS_FEEDBACK_OFFLINE_DIALOG_TEXT));
}

@ -529,7 +529,7 @@ void ChromeManagementAPIDelegate::InstallOrLaunchReplacementWebApp(
app_id, {web_app::proto::INSTALLED_WITHOUT_OS_INTEGRATION,
web_app::proto::INSTALLED_WITH_OS_INTEGRATION})) {
LaunchWebApp(
web_app::GenerateAppId(/*manifest_id=*/std::nullopt, web_app_url),
web_app::GenerateAppId(/*manifest_id_path=*/std::nullopt, web_app_url),
profile);
std::move(callback).Run(InstallOrLaunchWebAppResult::kSuccess);
return;
@ -647,8 +647,9 @@ void ChromeManagementAPIDelegate::ShowMv2DeprecationReEnableDialog(
return;
}
gfx::NativeWindow parent =
web_contents ? web_contents->GetTopLevelNativeWindow() : nullptr;
gfx::NativeWindow parent = web_contents
? web_contents->GetTopLevelNativeWindow()
: gfx::NativeWindow();
extensions::ShowMv2DeprecationReEnableDialog(
parent, extension.id(), extension.name(), std::move(done_callback));
}

@ -50,6 +50,7 @@
#include "extensions/common/features/feature_channel.h"
#include "net/base/file_stream.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/native_widget_types.h"
#if BUILDFLAG(IS_POSIX)
#include "base/files/file_descriptor_watcher_posix.h"
@ -295,7 +296,7 @@ TEST_F(NativeMessagingTest, EchoConnect) {
ASSERT_NO_FATAL_FAILURE(test_host.RegisterTestHost(false));
std::string error_message;
native_message_host_ = NativeMessageProcessHost::Create(
&profile_, NULL, ScopedTestNativeMessagingHost::kExtensionId,
&profile_, gfx::NativeView(), ScopedTestNativeMessagingHost::kExtensionId,
ScopedTestNativeMessagingHost::kHostName, false, &error_message);
native_message_host_->Start(this);
ASSERT_TRUE(native_message_host_);
@ -359,7 +360,7 @@ TEST_F(NativeMessagingTest, ReconnectArgs) {
ASSERT_NO_FATAL_FAILURE(test_host.RegisterTestHost(false));
std::string error_message;
native_message_host_ = NativeMessageProcessHost::Create(
&profile_, NULL, ScopedTestNativeMessagingHost::kExtensionId,
&profile_, gfx::NativeView(), ScopedTestNativeMessagingHost::kExtensionId,
ScopedTestNativeMessagingHost::
kSupportsNativeInitiatedConnectionsHostName,
false, &error_message);
@ -413,7 +414,7 @@ TEST_F(NativeMessagingTest, ReconnectArgs_Disabled) {
ASSERT_NO_FATAL_FAILURE(test_host.RegisterTestHost(false));
std::string error_message;
native_message_host_ = NativeMessageProcessHost::Create(
&profile_, NULL, ScopedTestNativeMessagingHost::kExtensionId,
&profile_, gfx::NativeView(), ScopedTestNativeMessagingHost::kExtensionId,
ScopedTestNativeMessagingHost::
kSupportsNativeInitiatedConnectionsHostName,
false, &error_message);
@ -441,7 +442,7 @@ TEST_F(NativeMessagingTest, ReconnectArgsIfNativeConnectionDisallowed) {
ASSERT_NO_FATAL_FAILURE(test_host.RegisterTestHost(false));
std::string error_message;
native_message_host_ = NativeMessageProcessHost::Create(
&profile_, NULL, ScopedTestNativeMessagingHost::kExtensionId,
&profile_, gfx::NativeView(), ScopedTestNativeMessagingHost::kExtensionId,
ScopedTestNativeMessagingHost::
kSupportsNativeInitiatedConnectionsHostName,
false, &error_message);
@ -470,7 +471,7 @@ TEST_F(NativeMessagingTest, UserLevel) {
std::string error_message;
native_message_host_ = NativeMessageProcessHost::Create(
&profile_, NULL, ScopedTestNativeMessagingHost::kExtensionId,
&profile_, gfx::NativeView(), ScopedTestNativeMessagingHost::kExtensionId,
ScopedTestNativeMessagingHost::kHostName, true, &error_message);
native_message_host_->Start(this);
ASSERT_TRUE(native_message_host_);
@ -488,7 +489,7 @@ TEST_F(NativeMessagingTest, DisallowUserLevel) {
std::string error_message;
native_message_host_ = NativeMessageProcessHost::Create(
&profile_, NULL, ScopedTestNativeMessagingHost::kExtensionId,
&profile_, gfx::NativeView(), ScopedTestNativeMessagingHost::kExtensionId,
ScopedTestNativeMessagingHost::kHostName, false, &error_message);
native_message_host_->Start(this);
ASSERT_TRUE(native_message_host_);

@ -35,6 +35,7 @@
#include "extensions/common/mojom/message_port.mojom-shared.h"
#include "extensions/common/permissions/permission_set.h"
#include "extensions/common/permissions/permissions_data.h"
#include "ui/gfx/native_widget_types.h"
namespace extensions {
namespace {
@ -75,9 +76,9 @@ class NativeMessagingHostErrorReporter : public NativeMessageHost::Client {
NativeMessageProcessHost::CreateWithLauncher(
extension_id, host_id,
NativeProcessLauncher::CreateDefault(
/* allow_user_level = */ true,
/* native_view = */ nullptr, profile->GetPath(),
/* require_native_initiated_connections = */ false,
/* allow_user_level_hosts= */ true,
/* native_view= */ gfx::NativeView(), profile->GetPath(),
/* require_native_initiated_connections= */ false,
connection_id, error_arg, profile));
MovableScopedKeepAlive keep_alive(
new ScopedKeepAlive(KeepAliveOrigin::NATIVE_MESSAGING_HOST_ERROR_REPORT,
@ -240,9 +241,9 @@ void LaunchNativeMessageHostFromNativeApp(const ExtensionId& extension_id,
auto native_message_host = NativeMessageProcessHost::CreateWithLauncher(
extension_id, host_id,
NativeProcessLauncher::CreateDefault(
/* allow_user_level = */ true, /* native_view = */ nullptr,
profile->GetPath(),
/* require_native_initiated_connections = */ true, connection_id, "",
/* allow_user_level_hosts= */ true,
/* native_view= */ gfx::NativeView(), profile->GetPath(),
/* require_native_initiated_connections= */ true, connection_id, "",
profile));
auto native_message_port = std::make_unique<extensions::NativeMessagePort>(
message_service->GetChannelDelegate(), port_id,

@ -101,7 +101,8 @@ gfx::NativeWindow ChromeExtensionFunctionDetails::GetNativeWindowForUI() {
// If there are no browser windows open, no window is available.
// This could happen e.g. if extension launches a long process or simple
// sleep() in the background script, during which browser is closed.
if (!browser)
return nullptr;
if (!browser) {
return gfx::NativeWindow();
}
return browser->window()->GetNativeWindow();
}

@ -13,6 +13,7 @@
#include "extensions/browser/extension_dialog_auto_confirm.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
#include "ui/gfx/native_widget_types.h"
#if !BUILDFLAG(IS_ANDROID)
#include "chrome/browser/ui/browser.h"
@ -100,7 +101,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionInstallPromptBrowserTest, NoParent) {
ScopedTestDialogAutoConfirm auto_confirm(ScopedTestDialogAutoConfirm::ACCEPT);
ExtensionInstallPrompt prompt(profile(), nullptr);
ExtensionInstallPrompt prompt(profile(), gfx::NativeWindow());
base::RunLoop run_loop;
ExtensionInstallPromptTestHelper helper(run_loop.QuitClosure());
prompt.ShowDialog(

@ -78,7 +78,7 @@ content::WebContents* ExtensionInstallPromptShowParams::GetParentWebContents() {
gfx::NativeWindow ExtensionInstallPromptShowParams::GetParentWindow() {
if (WasParentDestroyed()) {
return nullptr;
return gfx::NativeWindow();
}
if (WasConfiguredForWebContents()) {

@ -48,6 +48,7 @@
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/native_widget_types.h"
namespace extensions {
@ -441,7 +442,7 @@ void ExternalInstallError::OnFetchComplete() {
// to pass ones which may be invalidated.
install_ui_ = base::WrapUnique(
new ExtensionInstallPrompt(Profile::FromBrowserContext(browser_context_),
/*native_window=*/nullptr));
/*native_window=*/gfx::NativeWindow()));
install_ui_->ShowDialog(
base::BindOnce(&ExternalInstallError::OnInstallPromptDone,

@ -73,7 +73,7 @@ void LoadErrorReporter::ReportError(const std::u16string& message,
if (enable_noisy_errors_ && be_noisy) {
chrome::ShowWarningMessageBox(
nullptr,
gfx::NativeWindow(),
l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOAD_ERROR_ALERT_HEADING),
message);
}

@ -24,7 +24,7 @@ using content::BrowserThread;
ExternalProcessImporterHost::ExternalProcessImporterHost()
: headless_(false),
parent_window_(nullptr),
parent_window_(gfx::NativeWindow()),
observer_(nullptr),
profile_(nullptr),
is_source_readable_(true),

@ -54,6 +54,7 @@
#include "third_party/blink/public/mojom/mediastream/media_stream.mojom.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_capture_types.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/native_widget_types.h"
#include "url/origin.h"
#if BUILDFLAG(IS_CHROMEOS)
@ -116,7 +117,7 @@ gfx::NativeWindow FindParentWindowForWebContents(
return app_window->GetNativeWindow();
}
return nullptr;
return gfx::NativeWindow();
}
#endif

@ -17,6 +17,7 @@
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/controls/webview/webview.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
@ -26,8 +27,8 @@ namespace {
class NonTabWebView : public views::WidgetDelegate, public views::WebView {
public:
NonTabWebView(content::BrowserContext* browser_context, const GURL& url) {
auto* widget =
views::Widget::CreateWindowWithParent(this, /*parent=*/nullptr);
auto* widget = views::Widget::CreateWindowWithParent(
this, /*parent=*/gfx::NativeView());
widget->Show();
SetBrowserContext(browser_context);

@ -25,6 +25,7 @@
#include "printing/backend/print_backend.h"
#include "printing/buildflags/buildflags.h"
#include "printing/print_settings.h"
#include "ui/gfx/native_widget_types.h"
#if BUILDFLAG(IS_ANDROID)
#include "chrome/browser/android/tab_android.h"
@ -83,7 +84,7 @@ PrintingContextDelegate::~PrintingContextDelegate() = default;
gfx::NativeView PrintingContextDelegate::GetParentView() {
content::WebContents* wc = GetWebContents();
return wc ? wc->GetNativeView() : nullptr;
return wc ? wc->GetNativeView() : gfx::NativeView();
}
content::WebContents* PrintingContextDelegate::GetWebContents() {

@ -30,6 +30,7 @@
#include "components/web_modal/test_web_contents_modal_dialog_host.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/search_engines_data/resources/definitions/prepopulated_engines.h"
#include "ui/gfx/native_widget_types.h"
namespace {
@ -104,7 +105,8 @@ class ResizableDialogTestBrowserWindow : public DialogTestBrowserWindow {
GetTestWebContentsModalDialogHost() {
if (!dialog_host_) {
dialog_host_ =
std::make_unique<web_modal::TestWebContentsModalDialogHost>(nullptr);
std::make_unique<web_modal::TestWebContentsModalDialogHost>(
gfx::NativeView());
// Absurdly large size to ensure we don't run into "too small" issues.
dialog_host_->set_max_dialog_size(gfx::Size(5000, 5000));

@ -22,6 +22,7 @@
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_dialog_auto_confirm.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/native_widget_types.h"
namespace {
@ -147,7 +148,7 @@ void SupervisedUserExtensionsDelegateImpl::
&::OnParentPermissionDialogComplete, std::move(done_callback_));
gfx::NativeWindow parent_window =
contents ? contents->GetTopLevelNativeWindow() : nullptr;
contents ? contents->GetTopLevelNativeWindow() : gfx::NativeWindow();
parent_permission_dialog_ =
ParentPermissionDialog::CreateParentPermissionDialogForExtension(
Profile::FromBrowserContext(context_), parent_window, icon,

@ -11,6 +11,7 @@
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/test/test_browser_dialog.h"
#include "content/public/test/browser_test.h"
#include "ui/gfx/native_widget_types.h"
class AskGoogleForSuggestionsDialogTest : public DialogBrowserTest {
public:
@ -30,8 +31,9 @@ class AskGoogleForSuggestionsDialogTest : public DialogBrowserTest {
// The toolkit-views version of the dialog does not utilize the anchor_view
// and origin parameters passed to this function. Pass dummy values.
chrome::ShowConfirmBubble(browser()->window()->GetNativeWindow(), nullptr,
gfx::Point(), std::move(model));
chrome::ShowConfirmBubble(browser()->window()->GetNativeWindow(),
gfx::NativeView(), gfx::Point(),
std::move(model));
}
};

@ -9,6 +9,7 @@
#include <utility>
#include "components/autofill/core/browser/foundations/browser_autofill_manager_test_api.h"
#include "ui/gfx/native_widget_types.h"
namespace autofill {
@ -45,7 +46,7 @@ AutofillSuggestionControllerForTest::AutofillSuggestionControllerForTest(
web_contents,
PopupControllerCommon(element_bounds,
base::i18n::UNKNOWN_DIRECTION,
nullptr),
gfx::NativeView()),
#if !BUILDFLAG(IS_ANDROID)
/*form_control_ax_id=*/0
#endif

@ -279,7 +279,7 @@ TEST_F(AutofillSuggestionControllerTest, GetOrCreate) {
client().popup_controller(manager()).GetWeakPtr(),
manager().external_delegate().GetWeakPtrForTest(), nullptr,
PopupControllerCommon(std::move(bounds), base::i18n::UNKNOWN_DIRECTION,
nullptr),
gfx::NativeView()),
/*form_control_ax_id=*/0);
};
WeakPtr<AutofillSuggestionController> controller =
@ -348,7 +348,7 @@ TEST_F(AutofillSuggestionControllerTest, ProperlyResetController) {
client().popup_controller(manager()).GetWeakPtr(),
manager().external_delegate().GetWeakPtrForTest(), nullptr,
PopupControllerCommon(gfx::RectF(), base::i18n::UNKNOWN_DIRECTION,
nullptr),
gfx::NativeView()),
/*form_control_ax_id=*/0);
EXPECT_EQ(0, controller->GetLineCount());
}

@ -37,6 +37,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/test/test_clipboard.h"
#include "ui/gfx/native_widget_types.h"
using base::ASCIIToUTF16;
using bookmarks::BookmarkModel;
@ -131,8 +132,8 @@ TEST_F(BookmarkContextMenuControllerTest, DeleteURL) {
model_->bookmark_bar_node()->children().front().get(),
};
BookmarkContextMenuController controller(
nullptr, nullptr, nullptr, profile_.get(), BookmarkLaunchLocation::kNone,
nodes);
gfx::NativeWindow(), nullptr, nullptr, profile_.get(),
BookmarkLaunchLocation::kNone, nodes);
GURL url = model_->bookmark_bar_node()->children().front()->url();
ASSERT_TRUE(controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_REMOVE));
// Delete the URL.
@ -148,8 +149,8 @@ TEST_F(BookmarkContextMenuControllerTest, SingleURL) {
model_->bookmark_bar_node()->children().front().get(),
};
BookmarkContextMenuController controller(
nullptr, nullptr, nullptr, profile_.get(), BookmarkLaunchLocation::kNone,
nodes);
gfx::NativeWindow(), nullptr, nullptr, profile_.get(),
BookmarkLaunchLocation::kNone, nodes);
EXPECT_TRUE(controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_ALL));
EXPECT_TRUE(
controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW));
@ -168,8 +169,8 @@ TEST_F(BookmarkContextMenuControllerTest, MultipleURLs) {
model_->bookmark_bar_node()->children()[1]->children()[0].get(),
};
BookmarkContextMenuController controller(
nullptr, nullptr, nullptr, profile_.get(), BookmarkLaunchLocation::kNone,
nodes);
gfx::NativeWindow(), nullptr, nullptr, profile_.get(),
BookmarkLaunchLocation::kNone, nodes);
EXPECT_TRUE(controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_ALL));
EXPECT_TRUE(
controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW));
@ -187,8 +188,8 @@ TEST_F(BookmarkContextMenuControllerTest, SingleFolder) {
model_->bookmark_bar_node()->children()[2].get(),
};
BookmarkContextMenuController controller(
nullptr, nullptr, nullptr, profile_.get(), BookmarkLaunchLocation::kNone,
nodes);
gfx::NativeWindow(), nullptr, nullptr, profile_.get(),
BookmarkLaunchLocation::kNone, nodes);
EXPECT_FALSE(controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_ALL));
EXPECT_FALSE(
controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW));
@ -207,8 +208,8 @@ TEST_F(BookmarkContextMenuControllerTest, MultipleEmptyFolders) {
model_->bookmark_bar_node()->children()[3].get(),
};
BookmarkContextMenuController controller(
nullptr, nullptr, nullptr, profile_.get(), BookmarkLaunchLocation::kNone,
nodes);
gfx::NativeWindow(), nullptr, nullptr, profile_.get(),
BookmarkLaunchLocation::kNone, nodes);
EXPECT_FALSE(controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_ALL));
EXPECT_FALSE(
controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW));
@ -227,8 +228,8 @@ TEST_F(BookmarkContextMenuControllerTest, MultipleFoldersWithURLs) {
model_->bookmark_bar_node()->children()[4].get(),
};
BookmarkContextMenuController controller(
nullptr, nullptr, nullptr, profile_.get(), BookmarkLaunchLocation::kNone,
nodes);
gfx::NativeWindow(), nullptr, nullptr, profile_.get(),
BookmarkLaunchLocation::kNone, nodes);
EXPECT_TRUE(controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_ALL));
EXPECT_TRUE(
controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW));
@ -253,9 +254,9 @@ TEST_F(BookmarkContextMenuControllerTest, DisableIncognito) {
std::vector<raw_ptr<const BookmarkNode, VectorExperimental>> nodes = {
model_->bookmark_bar_node()->children().front().get(),
};
BookmarkContextMenuController controller(nullptr, nullptr, nullptr, incognito,
BookmarkLaunchLocation::kNone,
nodes);
BookmarkContextMenuController controller(
gfx::NativeWindow(), nullptr, nullptr, incognito,
BookmarkLaunchLocation::kNone, nodes);
EXPECT_FALSE(controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_INCOGNITO));
EXPECT_FALSE(
controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO));
@ -267,7 +268,7 @@ TEST_F(BookmarkContextMenuControllerTest, DisabledItemsWithOtherNode) {
std::vector<raw_ptr<const BookmarkNode, VectorExperimental>> nodes{
model_->other_node()};
BookmarkContextMenuController controller(
nullptr, nullptr, nullptr, profile_.get(),
gfx::NativeWindow(), nullptr, nullptr, profile_.get(),
BookmarkLaunchLocation::kNone, nodes);
EXPECT_FALSE(controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_EDIT));
EXPECT_FALSE(controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_REMOVE));
@ -279,7 +280,7 @@ TEST_F(BookmarkContextMenuControllerTest, DisabledItemsWithOtherNode) {
std::vector<raw_ptr<const BookmarkNode, VectorExperimental>> nodes{
model_->account_other_node(), model_->other_node()};
BookmarkContextMenuController controller(
nullptr, nullptr, nullptr, profile_.get(),
gfx::NativeWindow(), nullptr, nullptr, profile_.get(),
BookmarkLaunchLocation::kNone, nodes);
EXPECT_FALSE(controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_EDIT));
EXPECT_FALSE(controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_REMOVE));
@ -303,7 +304,7 @@ TEST_F(BookmarkContextMenuControllerTest,
for (const auto& nodes : nodes_selections) {
SCOPED_TRACE(NodesToString(nodes));
BookmarkContextMenuController controller(
nullptr, nullptr, nullptr, profile_.get(),
gfx::NativeWindow(), nullptr, nullptr, profile_.get(),
BookmarkLaunchLocation::kNone, nodes);
const bool has_urls = chrome::HasBookmarkURLs(nodes);
EXPECT_EQ(controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_ALL),
@ -348,7 +349,7 @@ TEST_F(BookmarkContextMenuControllerTest,
for (const auto& nodes : nodes_selections) {
SCOPED_TRACE(NodesToString(nodes));
BookmarkContextMenuController controller(
nullptr, nullptr, nullptr, profile_.get(),
gfx::NativeWindow(), nullptr, nullptr, profile_.get(),
BookmarkLaunchLocation::kNone, nodes);
EXPECT_FALSE(
controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_ADD_TO_BOOKMARKS_BAR));
@ -367,8 +368,8 @@ TEST_F(BookmarkContextMenuControllerTest,
ASSERT_NE(node->parent()->type(), BookmarkNode::Type::BOOKMARK_BAR);
BookmarkContextMenuController controller(
nullptr, nullptr, nullptr, profile_.get(), BookmarkLaunchLocation::kNone,
nodes);
gfx::NativeWindow(), nullptr, nullptr, profile_.get(),
BookmarkLaunchLocation::kNone, nodes);
EXPECT_TRUE(
controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_ADD_TO_BOOKMARKS_BAR));
EXPECT_FALSE(controller.IsCommandIdEnabled(
@ -381,7 +382,7 @@ TEST_F(BookmarkContextMenuControllerTest, CutCopyPasteNode) {
model_->bookmark_bar_node()->children()[0].get(),
};
std::unique_ptr<BookmarkContextMenuController> controller(
new BookmarkContextMenuController(nullptr, nullptr, nullptr,
new BookmarkContextMenuController(gfx::NativeWindow(), nullptr, nullptr,
profile_.get(),
BookmarkLaunchLocation::kNone, nodes));
EXPECT_TRUE(controller->IsCommandIdEnabled(IDC_COPY));
@ -391,8 +392,8 @@ TEST_F(BookmarkContextMenuControllerTest, CutCopyPasteNode) {
controller->ExecuteCommand(IDC_COPY, 0);
controller = base::WrapUnique(new BookmarkContextMenuController(
nullptr, nullptr, nullptr, profile_.get(), BookmarkLaunchLocation::kNone,
nodes));
gfx::NativeWindow(), nullptr, nullptr, profile_.get(),
BookmarkLaunchLocation::kNone, nodes));
size_t old_count = bb_node->children().size();
controller->ExecuteCommand(IDC_PASTE, 0);
@ -401,8 +402,8 @@ TEST_F(BookmarkContextMenuControllerTest, CutCopyPasteNode) {
ASSERT_EQ(bb_node->children()[0]->url(), bb_node->children()[1]->url());
controller = base::WrapUnique(new BookmarkContextMenuController(
nullptr, nullptr, nullptr, profile_.get(), BookmarkLaunchLocation::kNone,
nodes));
gfx::NativeWindow(), nullptr, nullptr, profile_.get(),
BookmarkLaunchLocation::kNone, nodes));
// Cut the URL.
controller->ExecuteCommand(IDC_CUT, 0);
ASSERT_TRUE(bb_node->children()[0]->is_url());
@ -413,8 +414,8 @@ TEST_F(BookmarkContextMenuControllerTest, CutCopyPasteNode) {
TEST_F(BookmarkContextMenuControllerTest,
ManagedShowAppsShortcutInBookmarksBar) {
BookmarkContextMenuController controller(
nullptr, nullptr, nullptr, profile_.get(), BookmarkLaunchLocation::kNone,
{model_->other_node()});
gfx::NativeWindow(), nullptr, nullptr, profile_.get(),
BookmarkLaunchLocation::kNone, {model_->other_node()});
// By default, the pref is not managed and the command is enabled.
sync_preferences::TestingPrefServiceSyncable* prefs =
@ -439,8 +440,8 @@ TEST_F(BookmarkContextMenuControllerTest,
TEST_F(BookmarkContextMenuControllerTest, ShowTabGroupsPref) {
BookmarkContextMenuController controller(
nullptr, nullptr, nullptr, profile_.get(), BookmarkLaunchLocation::kNone,
{model_->bookmark_bar_node()});
gfx::NativeWindow(), nullptr, nullptr, profile_.get(),
BookmarkLaunchLocation::kNone, {model_->bookmark_bar_node()});
EXPECT_TRUE(
controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_TOGGLE_SHOW_TAB_GROUPS));
@ -484,7 +485,7 @@ TEST_F(BookmarkContextMenuControllerTest, GetParentForNewNodesSelectionURL) {
ASSERT_TRUE(parent);
EXPECT_EQ(*parent.get(), BookmarkParentFolder::BookmarkBarFolder());
BookmarkContextMenuController controller(
nullptr, nullptr, nullptr, profile_.get(),
gfx::NativeWindow(), nullptr, nullptr, profile_.get(),
BookmarkLaunchLocation::kNone, nodes);
// New nodes added just after page.
EXPECT_EQ(controller.GetIndexForNewNodes(), page_index + 1u);
@ -514,7 +515,7 @@ TEST_F(BookmarkContextMenuControllerTest,
ASSERT_TRUE(parent);
EXPECT_EQ(*parent.get(), BookmarkParentFolder::OtherFolder());
BookmarkContextMenuController controller(
nullptr, nullptr, nullptr, profile_.get(),
gfx::NativeWindow(), nullptr, nullptr, profile_.get(),
BookmarkLaunchLocation::kNone, nodes);
// New nodes added just after page.
EXPECT_EQ(controller.GetIndexForNewNodes(), other_folder_children_count);
@ -532,8 +533,8 @@ TEST_F(BookmarkContextMenuControllerTest,
ASSERT_TRUE(parent);
EXPECT_EQ(*parent.get(), BookmarkParentFolder::FromFolderNode(folder_node));
BookmarkContextMenuController controller(
nullptr, nullptr, nullptr, profile_.get(), BookmarkLaunchLocation::kNone,
nodes);
gfx::NativeWindow(), nullptr, nullptr, profile_.get(),
BookmarkLaunchLocation::kNone, nodes);
EXPECT_EQ(controller.GetIndexForNewNodes(), 0u);
}

@ -17,6 +17,7 @@
#include "components/prefs/pref_service.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/shell_dialogs/select_file_dialog.h"
#if defined(USE_AURA)
@ -48,9 +49,9 @@ class FileSelectionUser : public ui::SelectFileDialog::Listener {
const std::u16string title = std::u16string();
file_selection_initialisation_in_progress = true;
select_file_dialog_->SelectFile(ui::SelectFileDialog::SELECT_OPEN_FILE,
title, file_path, nullptr, 0,
base::FilePath::StringType(), nullptr);
select_file_dialog_->SelectFile(
ui::SelectFileDialog::SELECT_OPEN_FILE, title, file_path, nullptr, 0,
base::FilePath::StringType(), gfx::NativeWindow());
file_selection_initialisation_in_progress = false;
}

@ -45,6 +45,7 @@
#include "ui/base/models/image_model.h"
#include "ui/color/color_provider_manager.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/native_theme/native_theme.h"
using extensions::ActionInfo;
@ -367,7 +368,7 @@ void ExtensionActionViewController::HidePopup() {
}
gfx::NativeView ExtensionActionViewController::GetPopupNativeView() {
return popup_host_ ? popup_host_->view()->GetNativeView() : nullptr;
return popup_host_ ? popup_host_->view()->GetNativeView() : gfx::NativeView();
}
ui::MenuModel* ExtensionActionViewController::GetContextMenu(

@ -19,6 +19,7 @@
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registrar.h"
#include "extensions/browser/extension_system.h"
#include "ui/gfx/native_widget_types.h"
#if !BUILDFLAG(IS_CHROMEOS)
#include "chrome/browser/ui/profiles/profile_picker.h"
@ -36,7 +37,7 @@ ExtensionEnableFlow::~ExtensionEnableFlow() = default;
void ExtensionEnableFlow::StartForWebContents(
content::WebContents* parent_contents) {
parent_contents_ = parent_contents;
parent_window_ = nullptr;
parent_window_ = gfx::NativeWindow();
Run();
}
@ -158,9 +159,9 @@ void ExtensionEnableFlow::CheckPermissionAndMaybePromptUser() {
}
void ExtensionEnableFlow::CreatePrompt() {
prompt_.reset(parent_contents_
? new ExtensionInstallPrompt(parent_contents_)
: new ExtensionInstallPrompt(profile_, nullptr));
prompt_.reset(parent_contents_ ? new ExtensionInstallPrompt(parent_contents_)
: new ExtensionInstallPrompt(
profile_, gfx::NativeWindow()));
}
void ExtensionEnableFlow::OnExtensionApprovalDone(

@ -35,6 +35,7 @@
#include "third_party/blink/public/mojom/manifest/display_mode.mojom.h"
#include "ui/base/models/image_model.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/native_widget_types.h"
#include "url/gurl.h"
namespace extensions {
@ -186,7 +187,8 @@ void HostedAppBrowserController::Uninstall(
DCHECK(!uninstall_dialog_);
uninstall_dialog_ = ExtensionUninstallDialog::Create(
browser()->profile(),
browser()->window() ? browser()->window()->GetNativeWindow() : nullptr,
browser()->window() ? browser()->window()->GetNativeWindow()
: gfx::NativeWindow(),
this);
// The dialog can be closed by UI system whenever it likes, but

@ -61,13 +61,15 @@ void ShowProfileErrorDialog(ProfileErrorType type,
g_is_showing_profile_error_dialog = true;
chrome::ShowWarningMessageBoxWithCheckbox(
nullptr, l10n_util::GetStringUTF16(IDS_PROFILE_ERROR_DIALOG_TITLE),
gfx::NativeWindow(),
l10n_util::GetStringUTF16(IDS_PROFILE_ERROR_DIALOG_TITLE),
l10n_util::GetStringUTF16(message_id),
l10n_util::GetStringUTF16(IDS_PROFILE_ERROR_DIALOG_CHECKBOX),
base::BindOnce(&OnProfileErrorDialogDismissed, diagnostics));
#else // BUILDFLAG(GOOGLE_CHROME_BRANDING)
chrome::ShowWarningMessageBox(
nullptr, l10n_util::GetStringUTF16(IDS_PROFILE_ERROR_DIALOG_TITLE),
gfx::NativeWindow(),
l10n_util::GetStringUTF16(IDS_PROFILE_ERROR_DIALOG_TITLE),
l10n_util::GetStringUTF16(message_id));
#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING)

@ -46,6 +46,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/resource/scoped_startup_resource_bundle.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/views_switches.h"
#if BUILDFLAG(IS_ANDROID)
@ -261,5 +262,5 @@ void MaybeShowInvalidUserDataDirWarningDialog() {
IDS_CANT_WRITE_USER_DIRECTORY_SUMMARY, user_data_dir.LossyDisplayName());
// More complex dialogs cannot be shown before the earliest calls here.
chrome::ShowWarningMessageBox(nullptr, title, message);
chrome::ShowWarningMessageBox(gfx::NativeWindow(), title, message);
}

@ -241,7 +241,7 @@ std::unique_ptr<views::Widget> TabDialogManager::CreateTabScopedDialog(
tab_interface_->GetBrowserWindowInterface()->TopContainer()->GetWidget();
CHECK(host);
return base::WrapUnique(views::DialogDelegate::CreateDialogWidget(
delegate, nullptr, host->GetNativeView()));
delegate, gfx::NativeWindow(), host->GetNativeView()));
}
void TabDialogManager::ShowDialogAndBlockTabInteraction(views::Widget* widget) {

@ -9,6 +9,7 @@
#include "chrome/browser/extensions/permissions/site_permissions_helper.h"
#include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h"
#include "ui/base/models/image_model.h"
#include "ui/gfx/native_widget_types.h"
TestToolbarActionViewController::TestToolbarActionViewController(
const std::string& id)
@ -79,7 +80,7 @@ void TestToolbarActionViewController::HidePopup() {
}
gfx::NativeView TestToolbarActionViewController::GetPopupNativeView() {
return nullptr;
return gfx::NativeView();
}
ui::MenuModel* TestToolbarActionViewController::GetContextMenu(

@ -167,7 +167,7 @@ class AppInfoDialogViewsTest : public BrowserWithTestWindowTest,
DCHECK(!widget_);
widget_ = views::DialogDelegate::CreateDialogWidget(
new views::DialogDelegateView(), GetContext(), nullptr);
new views::DialogDelegateView(), GetContext(), gfx::NativeView());
widget_->AddObserver(this);
dialog_ = widget_->GetContentsView()->AddChildView(
std::make_unique<AppInfoDialog>(profile, extension));

@ -16,6 +16,7 @@
#include "chrome/common/chrome_switches.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "ui/base/mojom/menu_source_type.mojom-forward.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/controls/menu/menu_item_view.h"
#include "ui/views/controls/menu/menu_model_adapter.h"
#include "ui/views/controls/menu/menu_runner.h"
@ -50,7 +51,8 @@ BookmarkContextMenu::BookmarkContextMenu(
selection,
bool close_on_remove)
: controller_(new BookmarkContextMenuController(
parent_widget ? parent_widget->GetNativeWindow() : nullptr,
parent_widget ? parent_widget->GetNativeWindow()
: gfx::NativeWindow(),
this,
browser,
profile,

@ -39,6 +39,7 @@
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/test/test_clipboard.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/controls/menu/menu_item_view.h"
#include "ui/views/test/scoped_views_test_helper.h"
@ -141,7 +142,7 @@ TEST_F(BookmarkContextMenuTest, OpenCount) {
// Should count F1's child but not F11's child, as that's what OpenAll would
// open.
EXPECT_EQ(2, chrome::OpenCount(nullptr, folder));
EXPECT_EQ(2, chrome::OpenCount(gfx::NativeWindow(), folder));
}
// Same as above, but for counting bookmarks that would be opened in an
@ -150,7 +151,7 @@ TEST_F(BookmarkContextMenuTest, OpenCountIncognito) {
const BookmarkNode* folder = model_->bookmark_bar_node()->children()[1].get();
// Should count f1a but not f2a, as that's what OpenAll would open.
EXPECT_EQ(1, chrome::OpenCount(nullptr, folder, profile_.get()));
EXPECT_EQ(1, chrome::OpenCount(gfx::NativeWindow(), folder, profile_.get()));
}
// Tests the enabled state of the menus when supplied a vector with a single

@ -53,6 +53,7 @@
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/background.h"
#include "ui/views/controls/button/checkbox.h"
@ -554,7 +555,7 @@ DesktopMediaPickerDialogView::DesktopMediaPickerDialogView(
views::Widget* widget = CreateMediaPickerDialogWidget(
modal_dialog ? chrome::FindBrowserWithTab(params.web_contents) : nullptr,
params.web_contents,
/*delegate=*/this, params.context, /*parent=*/nullptr);
/*delegate=*/this, params.context, /*parent=*/gfx::NativeView());
extensions::SecurityDialogTracker::GetInstance()->AddSecurityDialog(widget);

@ -37,6 +37,7 @@
#include "ui/base/ui_base_features.h"
#include "ui/color/color_id.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
@ -190,7 +191,7 @@ ShareThisTabDialogView::ShareThisTabDialogView(
// ModalType::kWindow.
SetModalType(ui::mojom::ModalType::kWindow);
#endif
CreateDialogWidget(this, params.context, nullptr)->Show();
CreateDialogWidget(this, params.context, gfx::NativeView())->Show();
}
source_view_->SetBorder(

@ -548,7 +548,7 @@ bool DownloadBubbleRowView::OnMouseDragged(const ui::MouseEvent& event) {
navigation_handler_->PreventDialogCloseOnDeactivate();
}
DragDownloadItem(info_->model()->GetDownloadItem(), &file_icon_,
widget ? widget->GetNativeView() : nullptr);
widget ? widget->GetNativeView() : gfx::NativeView());
// DragDownloadItem returns when the drag is over.
// `this` may be deleted by now!
}

@ -464,7 +464,7 @@ bool DownloadItemView::OnMouseDragged(const ui::MouseEvent& event) {
const views::Widget* const widget = GetWidget();
// TODO(shaktisahu): Make DragDownloadItem work with a model.
DragDownloadItem(model_->GetDownloadItem(), file_icon,
widget ? widget->GetNativeView() : nullptr);
widget ? widget->GetNativeView() : gfx::NativeView());
RecordDownloadShelfDragInfo(DownloadDragInfo::DRAG_STARTED);
}
return true;

@ -53,6 +53,7 @@
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/scroll_view.h"
@ -216,7 +217,7 @@ class ExtensionInstallDialogViewTest
ExtensionInstallDialogView* delegate_view = dialog.get();
views::Widget* modal_dialog = views::DialogDelegate::CreateDialogWidget(
dialog.release(), nullptr,
dialog.release(), gfx::NativeWindow(),
platform_util::GetViewForWindow(
browser()->window()->GetNativeWindow()));
modal_dialog->Show();
@ -604,7 +605,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewOnUninstallationTest,
base::DoNothing(), std::move(prompt));
views::Widget* modal_dialog = views::DialogDelegate::CreateDialogWidget(
dialog, nullptr,
dialog, gfx::NativeWindow(),
platform_util::GetViewForWindow(browser()->window()->GetNativeWindow()));
ASSERT_TRUE(modal_dialog);
views::test::WidgetDestroyedWaiter dialog_observer(modal_dialog);
@ -631,7 +632,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewOnUninstallationTest,
base::DoNothing(), std::move(prompt));
views::Widget* modal_dialog = views::DialogDelegate::CreateDialogWidget(
dialog, nullptr,
dialog, gfx::NativeWindow(),
platform_util::GetViewForWindow(browser()->window()->GetNativeWindow()));
ASSERT_TRUE(modal_dialog);
views::test::WidgetDestroyedWaiter dialog_observer(modal_dialog);
@ -675,7 +676,7 @@ void ExtensionInstallDialogRatingsSectionTest::TestRatingsSectionA11y(
base::DoNothing(), std::move(prompt));
views::Widget* modal_dialog = views::DialogDelegate::CreateDialogWidget(
dialog, nullptr,
dialog, gfx::NativeWindow(),
platform_util::GetViewForWindow(browser()->window()->GetNativeWindow()));
modal_dialog->Show();
@ -756,7 +757,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogWithWithholdPermissionsUI,
views::BubbleDialogDelegateView* delegate_view = dialog.get();
views::Widget* modal_dialog = views::DialogDelegate::CreateDialogWidget(
dialog.release(), nullptr,
dialog.release(), gfx::NativeWindow(),
platform_util::GetViewForWindow(browser()->window()->GetNativeWindow()));
modal_dialog->Show();
@ -791,7 +792,7 @@ class ExtensionInstallDialogViewRequestTest
ExtensionInstallDialogView* delegate_view = dialog.get();
views::Widget* modal_dialog = views::DialogDelegate::CreateDialogWidget(
dialog.release(), nullptr,
dialog.release(), gfx::NativeWindow(),
platform_util::GetViewForWindow(
browser()->window()->GetNativeWindow()));
modal_dialog->Show();

@ -18,6 +18,7 @@
#include "extensions/browser/extension_dialog_auto_confirm.h"
#include "extensions/browser/extension_icon_manager.h"
#include "extensions/common/extension.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/dialog_delegate.h"
@ -101,7 +102,7 @@ ExtensionInstallDialogViewTestSupervised::CreateAndShowPrompt(
ExtensionInstallDialogView* delegate_view = dialog.get();
views::Widget* modal_dialog = views::DialogDelegate::CreateDialogWidget(
dialog.release(), nullptr,
dialog.release(), gfx::NativeWindow(),
platform_util::GetViewForWindow(browser()->window()->GetNativeWindow()));
modal_dialog->Show();
@ -117,7 +118,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewTestSupervised, ChildAccepts) {
std::unique_ptr<ExtensionInstallPrompt::Prompt> prompt = CreatePrompt();
// Launch the extension install dialog.
ExtensionInstallPrompt install_prompt(profile(), nullptr);
ExtensionInstallPrompt install_prompt(profile(), gfx::NativeWindow());
base::RunLoop run_loop;
ExtensionInstallPromptTestHelper helper(run_loop.QuitClosure());
const extensions::Extension* const extension = prompt->extension();
@ -169,7 +170,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewTestSupervised,
std::unique_ptr<ExtensionInstallPrompt::Prompt> prompt = CreatePrompt();
// Launch the extension install dialog.
ExtensionInstallPrompt install_prompt(profile(), nullptr);
ExtensionInstallPrompt install_prompt(profile(), gfx::NativeWindow());
base::RunLoop run_loop;
ExtensionInstallPromptTestHelper helper(run_loop.QuitClosure());
const extensions::Extension* const extension = prompt->extension();

@ -71,7 +71,7 @@ class ExtensionInstallFrictionDialogViewTest
ExtensionInstallFrictionDialogView* delegate_view = dialog.get();
views::Widget* modal_dialog = views::DialogDelegate::CreateDialogWidget(
dialog.release(), nullptr,
dialog.release(), gfx::NativeWindow(),
platform_util::GetViewForWindow(
browser()->window()->GetNativeWindow()));
modal_dialog->Show();

@ -30,6 +30,7 @@
#include "net/test/embedded_test_server/controllable_http_response.h"
#include "ui/base/mojom/ui_base_types.mojom-shared.h"
#include "ui/events/base_event_utils.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/test/button_test_api.h"
#include "ui/views/test/widget_activation_waiter.h"
#include "ui/views/test/widget_test.h"
@ -86,8 +87,9 @@ views::UniqueWidgetPtr CreateTestTopLevelWidget() {
views::UniqueWidgetPtr CreateTestDialogWidget(views::Widget* parent) {
auto dialog_delegate = std::make_unique<views::DialogDelegateView>();
return std::unique_ptr<views::Widget>(
views::DialogDelegate::CreateDialogWidget(
dialog_delegate.release(), nullptr, parent->GetNativeView()));
views::DialogDelegate::CreateDialogWidget(dialog_delegate.release(),
gfx::NativeWindow(),
parent->GetNativeView()));
}
void ExpectWidgetDestroy(base::WeakPtr<views::Widget> widget) {

@ -106,7 +106,7 @@ void ExtensionsMenuTestUtil::Press(const extensions::ExtensionId& id) {
gfx::NativeView ExtensionsMenuTestUtil::GetPopupNativeView() {
ToolbarActionViewController* popup_owner =
extensions_container_->popup_owner_for_testing();
return popup_owner ? popup_owner->GetPopupNativeView() : nullptr;
return popup_owner ? popup_owner->GetPopupNativeView() : gfx::NativeView();
}
bool ExtensionsMenuTestUtil::HasPopup() {

@ -23,8 +23,9 @@ namespace {
views::UniqueWidgetPtr CreateTestDialogWidget(views::Widget* parent) {
auto dialog_delegate = std::make_unique<views::DialogDelegateView>();
return std::unique_ptr<views::Widget>(
views::DialogDelegate::CreateDialogWidget(
dialog_delegate.release(), nullptr, parent->GetNativeView()));
views::DialogDelegate::CreateDialogWidget(dialog_delegate.release(),
gfx::NativeWindow(),
parent->GetNativeView()));
}
} // namespace

@ -26,6 +26,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/link.h"
#include "ui/views/layout/box_layout.h"
@ -69,7 +70,9 @@ void FirstRunDialog::Show(base::RepeatingClosure learn_more_callback,
base::RepeatingClosure quit_runloop) {
FirstRunDialog* dialog = new FirstRunDialog(std::move(learn_more_callback),
std::move(quit_runloop));
views::DialogDelegate::CreateDialogWidget(dialog, nullptr, nullptr)->Show();
views::DialogDelegate::CreateDialogWidget(dialog, gfx::NativeWindow(),
gfx::NativeView())
->Show();
}
FirstRunDialog::FirstRunDialog(base::RepeatingClosure learn_more_callback,

@ -1624,7 +1624,7 @@ void BrowserView::SetZOrderLevel(ui::ZOrderLevel level) {
gfx::NativeWindow BrowserView::GetNativeWindow() const {
// While the browser destruction is going on, the widget can already be gone,
// but utility functions like FindBrowserWithWindow will still call this.
return GetWidget() ? GetWidget()->GetNativeWindow() : nullptr;
return GetWidget() ? GetWidget()->GetNativeWindow() : gfx::NativeWindow();
}
bool BrowserView::IsOnCurrentWorkspace() const {

@ -166,7 +166,7 @@ class BrowserViewLayout::WebContentsModalDialogHostViews
private:
gfx::NativeView GetHostView() const override {
views::Widget* const host_widget = GetHostWidget();
return host_widget ? host_widget->GetNativeView() : nullptr;
return host_widget ? host_widget->GetNativeView() : gfx::NativeView();
}
// Add/remove observer.

@ -12,6 +12,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/layout/fill_layout.h"
using base::UserMetricsAction;
@ -36,7 +37,7 @@ void ImportLockDialogView::Show(gfx::NativeWindow parent,
views::DialogDelegate::CreateDialogWidget(
new ImportLockDialogView(std::move(callback), importer_lock_title_id,
importer_lock_text_id),
nullptr, nullptr)
gfx::NativeWindow(), gfx::NativeView())
->Show();
base::RecordAction(UserMetricsAction("ImportLockDialogView_Shown"));
}

@ -189,7 +189,7 @@ void ParentToBrowser(Browser* browser,
// in fullscreen cases.
zoom_bubble->set_parent_window(
zoom_bubble->anchor_widget()
? nullptr
? gfx::NativeView()
: browser_view->GetWidget()->GetNativeView());
views::BubbleDialogDelegateView::CreateBubble(zoom_bubble);

@ -204,8 +204,8 @@ chrome::MessageBoxResult MessageBoxDialog::Show(
: ui::mojom::ModalType::kSystem);
widget = constrained_window::CreateBrowserModalDialogViews(dialog, parent);
} else {
widget =
views::DialogDelegate::CreateDialogWidget(dialog, nullptr, nullptr);
widget = views::DialogDelegate::CreateDialogWidget(
dialog, gfx::NativeWindow(), gfx::NativeView());
// Move the dialog's widget on top so other windows do not obscure it.
widget->SetZOrderLevel(ui::ZOrderLevel::kFloatingWindow);
}

@ -27,6 +27,7 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/color/color_id.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/background.h"
@ -177,7 +178,7 @@ EnterpriseStartupDialogView::EnterpriseStartupDialogView(
base::BindOnce(&EnterpriseStartupDialogView::RunDialogCallback,
base::Unretained(this), false));
SetBorder(views::CreateEmptyBorder(GetDialogInsets()));
CreateDialogWidget(this, nullptr, nullptr)->Show();
CreateDialogWidget(this, gfx::NativeWindow(), gfx::NativeView())->Show();
#if BUILDFLAG(IS_MAC)
base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask(
FROM_HERE, base::BindOnce(&EnterpriseStartupDialogView::StartModalDialog,

@ -17,6 +17,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/dialog_model.h"
#include "ui/base/models/image_model.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/paint_vector_icon.h"
namespace {
@ -66,7 +67,8 @@ void ShowExtensionInstallBlockedByParentDialog(
.SetDialogDestroyingCallback(std::move(done_callback))
.Build();
gfx::NativeWindow parent_window =
web_contents ? web_contents->GetTopLevelNativeWindow() : nullptr;
web_contents ? web_contents->GetTopLevelNativeWindow()
: gfx::NativeWindow();
constrained_window::ShowBrowserModal(std::move(dialog_model), parent_window);
}

@ -54,6 +54,7 @@
#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/border.h"
#include "ui/views/bubble/bubble_frame_view.h"
@ -684,10 +685,10 @@ void ParentPermissionDialogView::ShowDialogInternal() {
// from an extension.
CreateContents();
views::Widget* widget =
params_->window
? constrained_window::CreateBrowserModalDialogViews(this,
params_->window)
: views::DialogDelegate::CreateDialogWidget(this, nullptr, nullptr);
params_->window ? constrained_window::CreateBrowserModalDialogViews(
this, params_->window)
: views::DialogDelegate::CreateDialogWidget(
this, gfx::NativeWindow(), gfx::NativeView());
widget->Show();
if (test_view_observer) {

@ -37,7 +37,7 @@ ChromeWebContentsViewDelegateViewsMac::
gfx::NativeWindow ChromeWebContentsViewDelegateViewsMac::GetNativeWindow() {
Browser* browser = chrome::FindBrowserWithTab(web_contents_);
return browser ? browser->window()->GetNativeWindow() : nullptr;
return browser ? browser->window()->GetNativeWindow() : gfx::NativeWindow();
}
NSObject<RenderWidgetHostViewMacDelegate>*

@ -1986,7 +1986,7 @@ class CaptureLoseWindowFinder : public WindowFinder {
const std::set<gfx::NativeWindow>& ignore) override {
static_cast<views::View*>(tab_strip_->GetDragContext())
->OnMouseCaptureLost();
return nullptr;
return gfx::NativeWindow();
}
private:

@ -42,6 +42,7 @@
#include "ui/base/mojom/menu_source_type.mojom-forward.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_type.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
@ -125,8 +126,8 @@ task_manager::TaskManagerTableModel* TaskManagerView::Show(
// On Chrome OS, pressing Search-Esc when there are no open browser windows
// will open the task manager on the root window for new windows.
gfx::NativeWindow context =
browser ? browser->window()->GetNativeWindow() : nullptr;
CreateDialogWidget(g_task_manager_view, context, nullptr);
browser ? browser->window()->GetNativeWindow() : gfx::NativeWindow();
CreateDialogWidget(g_task_manager_view, context, gfx::NativeView());
g_task_manager_view->GetDialogClientView()->SetBackgroundColor(
kColorTaskManagerBackground);
g_task_manager_view->InitAlwaysOnTopState();

@ -19,6 +19,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/text_elider.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
@ -175,8 +176,8 @@ void ShowWebAppFileLaunchDialog(const std::vector<base::FilePath>& file_paths,
file_paths, profile, app_id, std::move(close_callback));
view->Init();
views::DialogDelegate::CreateDialogWidget(std::move(view),
/*context=*/nullptr,
/*parent=*/nullptr)
/*context=*/gfx::NativeWindow(),
/*parent=*/gfx::NativeView())
->Show();
}

@ -267,8 +267,8 @@ void IsolatedWebAppInstallerViewController::Show() {
widget_ =
views::DialogDelegate::CreateDialogWidget(std::move(dialog_delegate),
/*context=*/nullptr,
/*parent=*/nullptr);
/*context=*/gfx::NativeWindow(),
/*parent=*/gfx::NativeView());
CHECK(!window_);
window_ = widget_->GetNativeWindow();

@ -116,7 +116,7 @@ class IsolatedWebAppInstallerViewController
std::unique_ptr<views::View> contents_view);
std::string instance_id_;
gfx::NativeWindow window_ = nullptr;
gfx::NativeWindow window_ = gfx::NativeWindow();
gfx::ImageSkia icon_ = gfx::ImageSkia();
raw_ptr<Profile> profile_ = nullptr;

@ -15,6 +15,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/layout_provider.h"
@ -79,8 +80,8 @@ void ShowWebAppProtocolLaunchDialog(
url, profile, app_id, std::move(close_callback));
view->Init();
views::DialogDelegate::CreateDialogWidget(std::move(view),
/*context=*/nullptr,
/*parent=*/nullptr)
/*context=*/gfx::NativeWindow(),
/*parent=*/gfx::NativeView())
->Show();
}

@ -27,6 +27,7 @@
#include "third_party/blink/public/mojom/webid/federated_auth_request.mojom-shared.h"
#include "third_party/blink/public/mojom/webid/federated_auth_request.mojom.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/widget/widget.h"
@ -975,7 +976,7 @@ std::unique_ptr<views::Widget> FedCmAccountSelectionView::CreateDialogWidget() {
views::Widget* top_level_widget =
views::Widget::GetWidgetForNativeWindow(top_level_native_window);
dialog_widget = base::WrapUnique(views::DialogDelegate::CreateDialogWidget(
modal, /*context=*/nullptr,
modal, /*context=*/gfx::NativeWindow(),
/*parent=*/top_level_widget->GetNativeView()));
}

@ -63,6 +63,7 @@
#include "third_party/blink/public/mojom/manifest/manifest.mojom-shared.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/page_transition_types.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/native_window_tracker.h"
#include "url/gurl.h"
#include "url/origin.h"
@ -430,7 +431,7 @@ void WebAppUiManagerImpl::PresentUserUninstallDialog(
UninstallCompleteCallback callback) {
PresentUserUninstallDialog(
app_id, uninstall_source,
parent_window ? parent_window->GetNativeWindow() : nullptr,
parent_window ? parent_window->GetNativeWindow() : gfx::NativeWindow(),
std::move(callback), base::DoNothing());
}

@ -82,7 +82,7 @@ void FeedbackDialog::CreateOrShow(
current_instance_ = new FeedbackDialog(profile, info);
gfx::NativeWindow window =
chrome::ShowWebDialog(nullptr, profile, current_instance_,
chrome::ShowWebDialog(gfx::NativeView(), profile, current_instance_,
/*show=*/false);
current_instance_->widget_ = views::Widget::GetWidgetForNativeWindow(window);
views::View* root = current_instance_->widget_->GetRootView();

@ -1168,7 +1168,7 @@ class TestDialog : public views::DialogDelegateView {
case ui::mojom::ModalType::kSystem:
case ui::mojom::ModalType::kNone:
widget = views::DialogDelegate::CreateDialogWidget(
std::move(dialog), nullptr,
std::move(dialog), gfx::NativeWindow(),
BrowserView::GetBrowserViewForBrowser(parent)
->GetWidget()
->GetNativeView());

@ -22,6 +22,7 @@
#include "ui/base/mojom/ui_base_types.mojom-shared.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/bubble/bubble_dialog_model_host.h"
#include "ui/views/widget/native_widget.h"
#include "ui/views/widget/widget.h"
@ -275,7 +276,7 @@ views::Widget* CreateWebModalDialogViews(views::WidgetDelegate* dialog,
web_modal::ModalDialogHost* const dialog_host =
manager->delegate()->GetWebContentsModalDialogHost();
views::Widget* widget = views::DialogDelegate::CreateDialogWidget(
dialog, nullptr, dialog_host->GetHostView());
dialog, gfx::NativeWindow(), dialog_host->GetHostView());
std::unique_ptr<ModalDialogHostObserver> observer =
std::make_unique<ModalDialogHostObserverViews>(
dialog_host, widget, /*auto_update_position=*/false);
@ -301,9 +302,10 @@ views::Widget* CreateBrowserModalDialogViews(views::DialogDelegate* dialog,
DCHECK(!parent || CurrentBrowserModalClient());
gfx::NativeView parent_view =
parent ? CurrentBrowserModalClient()->GetDialogHostView(parent) : nullptr;
views::Widget* widget =
views::DialogDelegate::CreateDialogWidget(dialog, nullptr, parent_view);
parent ? CurrentBrowserModalClient()->GetDialogHostView(parent)
: gfx::NativeView();
views::Widget* widget = views::DialogDelegate::CreateDialogWidget(
dialog, gfx::NativeWindow(), parent_view);
widget->SetNativeWindowProperty(
views::kWidgetIdentifierKey,
const_cast<void*>(kConstrainedWindowWidgetIdentifier));
@ -342,7 +344,7 @@ views::Widget* ShowBrowserModal(std::unique_ptr<ui::DialogModel> dialog_model,
// dialogs support autosize.
bool will_use_custom_frame = views::DialogDelegate::CanSupportCustomFrame(
parent ? CurrentBrowserModalClient()->GetDialogHostView(parent)
: nullptr);
: gfx::NativeView());
auto dialog = views::BubbleDialogModelHost::CreateModal(
std::move(dialog_model), ui::mojom::ModalType::kWindow,
will_use_custom_frame);

@ -44,7 +44,7 @@ class TestConstrainedWindowViewsClient
return nullptr;
}
gfx::NativeView GetDialogHostView(gfx::NativeWindow parent) override {
return nullptr;
return gfx::NativeView();
}
};
@ -96,8 +96,8 @@ class ConstrainedWindowViewsTest : public views::ViewsTestBase {
auto contents = std::make_unique<views::StaticSizedView>();
contents_ = delegate_->SetContentsView(std::move(contents));
dialog_ = views::DialogDelegate::CreateDialogWidget(delegate_.get(),
GetContext(), nullptr);
dialog_ = views::DialogDelegate::CreateDialogWidget(
delegate_.get(), GetContext(), gfx::NativeView());
// Create a dialog host sufficiently large enough to accommodate dialog
// size changes during testing.
@ -229,7 +229,7 @@ TEST_F(ConstrainedWindowViewsTest, MAYBE_NullModalParent) {
auto delegate = std::make_unique<views::DialogDelegate>();
delegate->SetModalType(ui::mojom::ModalType::kWindow);
views::Widget* widget =
CreateBrowserModalDialogViews(delegate.get(), nullptr);
CreateBrowserModalDialogViews(delegate.get(), gfx::NativeWindow());
widget->Show();
EXPECT_TRUE(widget->IsVisible());
widget->CloseNow();

@ -2244,7 +2244,7 @@ void RenderWidgetHostViewMac::ForwardKeyboardEventWithCommands(
}
const blink::WebKeyboardEvent& keyboard_event =
static_cast<const blink::WebKeyboardEvent&>(input_event->Event());
input::NativeWebKeyboardEvent native_event(keyboard_event, nil);
input::NativeWebKeyboardEvent native_event(keyboard_event, gfx::NativeView());
native_event.skip_if_unhandled = skip_if_unhandled;
// The NSEvent constructed from the InputEvent sent over mojo is not even
// close to the original NSEvent, resulting in all sorts of bugs. Use the

@ -136,8 +136,9 @@ gfx::NativeView WebContentsViewMac::GetNativeView() const {
gfx::NativeView WebContentsViewMac::GetContentNativeView() const {
RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView();
if (!rwhv)
return nullptr;
if (!rwhv) {
return gfx::NativeView();
}
return rwhv->GetNativeView();
}
@ -149,7 +150,7 @@ gfx::NativeWindow WebContentsViewMac::GetTopLevelNativeWindow() const {
if (delegate_) {
return delegate_->GetNativeWindow();
}
return nullptr;
return gfx::NativeWindow();
}
gfx::Rect WebContentsViewMac::GetContainerBounds() const {

@ -4,6 +4,8 @@
#include "extensions/browser/mock_screen.h"
#include "ui/gfx/native_widget_types.h"
namespace extensions {
MockScreen::MockScreen() {
@ -27,13 +29,13 @@ bool MockScreen::IsWindowUnderCursor(gfx::NativeWindow window) {
}
gfx::NativeWindow MockScreen::GetWindowAtScreenPoint(const gfx::Point& point) {
return nullptr;
return gfx::NativeWindow();
}
gfx::NativeWindow MockScreen::GetLocalProcessWindowAtPoint(
const gfx::Point& point,
const std::set<gfx::NativeWindow>& ignore) {
return nullptr;
return gfx::NativeWindow();
}
int MockScreen::GetNumDisplays() const {

@ -85,7 +85,7 @@ void ShellNativeAppWindow::SetZOrderLevel(ui::ZOrderLevel level) {
gfx::NativeView ShellNativeAppWindow::GetHostView() const {
NOTIMPLEMENTED();
return nullptr;
return gfx::NativeView();
}
gfx::Point ShellNativeAppWindow::GetDialogPosition(const gfx::Size& size) {

@ -39,13 +39,13 @@ bool HeadlessScreen::IsWindowUnderCursor(gfx::NativeWindow window) {
gfx::NativeWindow HeadlessScreen::GetWindowAtScreenPoint(
const gfx::Point& point) {
return nullptr;
return gfx::NativeWindow();
}
gfx::NativeWindow HeadlessScreen::GetLocalProcessWindowAtPoint(
const gfx::Point& point,
const std::set<gfx::NativeWindow>& ignore) {
return nullptr;
return gfx::NativeWindow();
}
display::Display HeadlessScreen::GetDisplayNearestWindow(

@ -340,7 +340,7 @@ class ScreenMac : public Screen {
const std::set<gfx::NativeWindow>& ignore) override {
const NSPoint ns_point = gfx::ScreenPointToNSPoint(point);
// Note: [NSApp orderedWindows] doesn't include NSPanels.
// Note: NSApp.orderedWindows doesn't include NSPanels.
for (NSWindow* window in NSApp.orderedWindows) {
if (ignore.count(gfx::NativeWindow(window))) {
continue;
@ -361,7 +361,7 @@ class ScreenMac : public Screen {
}
}
return nil;
return gfx::NativeWindow();
}
int GetNumDisplays() const override { return displays_mac_.size(); }

@ -127,8 +127,7 @@ using NativeEvent = base::apple::OwnedNSEvent;
// underlying NSView or NSWindow <https://crbug.com/40597366>.
class COMPONENT_EXPORT(GFX) NativeView : public base::apple::WeakNSView {
public:
// TODO(avi): Remove the nullptr argument and make construction be explicit.
NativeView(std::nullptr_t = nullptr);
NativeView();
#ifdef __OBJC__
explicit NativeView(NSView* ns_view);
// This function name is verbose (that is, not just GetNSView) so that it
@ -142,8 +141,7 @@ class COMPONENT_EXPORT(GFX) NativeView : public base::apple::WeakNSView {
};
class COMPONENT_EXPORT(GFX) NativeWindow : public base::apple::WeakNSWindow {
public:
// TODO(avi): Remove the nullptr argument and make construction be explicit.
NativeWindow(std::nullptr_t = nullptr);
NativeWindow();
#ifdef __OBJC__
explicit NativeWindow(NSWindow* ns_window);
// This function name is verbose (that is, not just GetNSWindow) so that it

@ -10,7 +10,7 @@
namespace gfx {
NativeView::NativeView(std::nullptr_t) {}
NativeView::NativeView() = default;
NativeView::NativeView(NSView* ns_view) : base::apple::WeakNSView(ns_view) {}
@ -22,7 +22,7 @@ std::string NativeView::ToString() const {
return base::SysNSStringToUTF8(GetNativeNSView().description);
}
NativeWindow::NativeWindow(std::nullptr_t) {}
NativeWindow::NativeWindow() = default;
NativeWindow::NativeWindow(NSWindow* ns_window)
: base::apple::WeakNSWindow(ns_window),

@ -1515,7 +1515,7 @@ void MenuController::OnWidgetDestroying(Widget* widget) {
DCHECK_EQ(owner_, widget);
owner_->RemoveObserver(this);
owner_ = nullptr;
native_view_for_gestures_ = nullptr;
native_view_for_gestures_ = gfx::NativeView();
#if BUILDFLAG(IS_MAC)
menu_closure_animation_.reset();

@ -21,6 +21,7 @@
#include "ui/events/gestures/gesture_recognizer.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/controls/menu/menu_controller.h"
#include "ui/views/controls/menu/menu_host_root_view.h"
@ -372,7 +373,7 @@ gfx::Insets MenuHost::GetCustomInsetsInDIP() const {
void MenuHost::OnWidgetDestroying(Widget* widget) {
DCHECK_EQ(GetOwner(), widget);
owner_observation_.Reset();
native_view_for_gestures_ = nullptr;
native_view_for_gestures_ = gfx::NativeView();
}
Widget* MenuHost::GetOwner() {

@ -16,6 +16,7 @@
#include "ui/base/mojom/menu_source_type.mojom-shared.h"
#include "ui/events/event_utils.h"
#import "ui/events/test/cocoa_test_event_utils.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/menus/cocoa/menu_controller.h"
#include "ui/menus/simple_menu_model.h"
#include "ui/views/controls/menu/menu_cocoa_watcher_mac.h"
@ -174,7 +175,7 @@ class MenuRunnerCocoaTest : public ViewsTestBase,
runner_->RunMenuAt(
parent_, nullptr, gfx::Rect(), MenuAnchorPosition::kTopLeft,
ui::mojom::MenuSourceType::kNone, MenuRunner::CONTEXT_MENU, nullptr);
ui::mojom::MenuSourceType::kNone, MenuRunner::CONTEXT_MENU);
MaybeRunAsync();
}

@ -23,6 +23,7 @@
#include "ui/display/screen.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/test/event_generator.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/menu/menu_controller.h"
@ -147,10 +148,9 @@ class MenuRunnerTest : public ViewsTestBase {
base::RepeatingClosure quit_closure = task_environment()->QuitClosure();
task_environment()->GetMainThreadTaskRunner()->PostTask(
FROM_HERE, base::BindLambdaForTesting([&]() {
menu_runner()->RunMenuAt(owner(), nullptr,
gfx::Rect(anchor_position, gfx::Size()),
MenuAnchorPosition::kTopLeft,
ui::mojom::MenuSourceType::kMouse, nullptr);
menu_runner()->RunMenuAt(
owner(), nullptr, gfx::Rect(anchor_position, gfx::Size()),
MenuAnchorPosition::kTopLeft, ui::mojom::MenuSourceType::kMouse);
quit_closure.Run();
}));
task_environment()->RunUntilQuit();
@ -172,7 +172,7 @@ TEST_F(MenuRunnerTest, AsynchronousRun) {
InitMenuRunner(0);
MenuRunner* runner = menu_runner();
runner->RunMenuAt(owner(), nullptr, gfx::Rect(), MenuAnchorPosition::kTopLeft,
ui::mojom::MenuSourceType::kNone, nullptr);
ui::mojom::MenuSourceType::kNone);
EXPECT_TRUE(runner->IsRunning());
runner->Cancel();
@ -188,7 +188,7 @@ TEST_F(MenuRunnerTest, AsynchronousKeyEventHandling) {
InitMenuRunner(0);
MenuRunner* runner = menu_runner();
runner->RunMenuAt(owner(), nullptr, gfx::Rect(), MenuAnchorPosition::kTopLeft,
ui::mojom::MenuSourceType::kNone, nullptr);
ui::mojom::MenuSourceType::kNone);
EXPECT_TRUE(runner->IsRunning());
ui::test::EventGenerator generator(GetContext(), owner()->GetNativeWindow());
@ -216,7 +216,7 @@ TEST_F(MenuRunnerTest, MAYBE_LatinMnemonic) {
InitMenuRunner(0);
MenuRunner* runner = menu_runner();
runner->RunMenuAt(owner(), nullptr, gfx::Rect(), MenuAnchorPosition::kTopLeft,
ui::mojom::MenuSourceType::kNone, nullptr);
ui::mojom::MenuSourceType::kNone);
EXPECT_TRUE(runner->IsRunning());
ui::test::EventGenerator generator(GetContext(), owner()->GetNativeWindow());
@ -241,7 +241,7 @@ TEST_F(MenuRunnerTest, NonLatinMnemonic) {
InitMenuRunner(0);
MenuRunner* runner = menu_runner();
runner->RunMenuAt(owner(), nullptr, gfx::Rect(), MenuAnchorPosition::kTopLeft,
ui::mojom::MenuSourceType::kNone, nullptr);
ui::mojom::MenuSourceType::kNone);
EXPECT_TRUE(runner->IsRunning());
ui::test::EventGenerator generator(GetContext(), owner()->GetNativeWindow());
@ -266,7 +266,7 @@ TEST_F(MenuRunnerTest, MenuItemViewShowsMnemonics) {
menu_runner()->RunMenuAt(owner(), nullptr, gfx::Rect(),
MenuAnchorPosition::kTopLeft,
ui::mojom::MenuSourceType::kNone, nullptr);
ui::mojom::MenuSourceType::kNone);
EXPECT_TRUE(menu_item_view()->show_mnemonics());
}
@ -280,7 +280,7 @@ TEST_F(MenuRunnerTest, MenuItemViewDoesNotShowMnemonics) {
menu_runner()->RunMenuAt(owner(), nullptr, gfx::Rect(),
MenuAnchorPosition::kTopLeft,
ui::mojom::MenuSourceType::kNone, nullptr);
ui::mojom::MenuSourceType::kNone);
EXPECT_FALSE(menu_item_view()->show_mnemonics());
}
@ -305,7 +305,7 @@ TEST_F(MenuRunnerTest, PrefixSelect) {
MenuRunner* runner = menu_runner();
runner->RunMenuAt(owner(), nullptr, gfx::Rect(), MenuAnchorPosition::kTopLeft,
ui::mojom::MenuSourceType::kNone, nullptr);
ui::mojom::MenuSourceType::kNone);
EXPECT_TRUE(runner->IsRunning());
menu_item_view()
@ -349,7 +349,7 @@ TEST_F(MenuRunnerTest, SpaceActivatesItem) {
MenuRunner* runner = menu_runner();
runner->RunMenuAt(owner(), nullptr, gfx::Rect(), MenuAnchorPosition::kTopLeft,
ui::mojom::MenuSourceType::kNone, nullptr);
ui::mojom::MenuSourceType::kNone);
EXPECT_TRUE(runner->IsRunning());
ui::test::EventGenerator generator(GetContext(), owner()->GetNativeWindow());
@ -373,7 +373,7 @@ TEST_F(MenuRunnerTest, NestingDuringDrag) {
InitMenuRunner(MenuRunner::FOR_DROP);
MenuRunner* runner = menu_runner();
runner->RunMenuAt(owner(), nullptr, gfx::Rect(), MenuAnchorPosition::kTopLeft,
ui::mojom::MenuSourceType::kNone, nullptr);
ui::mojom::MenuSourceType::kNone);
EXPECT_TRUE(runner->IsRunning());
auto nested_delegate = std::make_unique<TestMenuDelegate>();
@ -382,7 +382,7 @@ TEST_F(MenuRunnerTest, NestingDuringDrag) {
MenuRunner::IS_NESTED));
nested_runner.RunMenuAt(owner(), nullptr, gfx::Rect(),
MenuAnchorPosition::kTopLeft,
ui::mojom::MenuSourceType::kNone, nullptr);
ui::mojom::MenuSourceType::kNone);
EXPECT_TRUE(nested_runner.IsRunning());
EXPECT_FALSE(runner->IsRunning());
EXPECT_EQ(1, menu_delegate()->on_menu_closed_called());
@ -536,7 +536,7 @@ class MenuLauncherEventHandler : public ui::EventHandler {
if (event->type() == ui::EventType::kMousePressed) {
runner_->RunMenuAt(owner_, nullptr, gfx::Rect(),
MenuAnchorPosition::kTopLeft,
ui::mojom::MenuSourceType::kNone, nullptr);
ui::mojom::MenuSourceType::kNone);
event->SetHandled();
}
}
@ -719,7 +719,7 @@ TEST_F(MenuRunnerImplTest, MenuRunnerDestroyedWithNoActiveController) {
new internal::MenuRunnerImpl(CreateMenuItemView());
menu_runner->RunMenuAt(owner(), nullptr, gfx::Rect(),
MenuAnchorPosition::kTopLeft,
ui::mojom::MenuSourceType::kNone, 0, nullptr);
ui::mojom::MenuSourceType::kNone, 0);
// Hide the menu, and clear its item selection state.
MenuControllerTestApi menu_controller;
@ -734,7 +734,7 @@ TEST_F(MenuRunnerImplTest, MenuRunnerDestroyedWithNoActiveController) {
base::WrapUnique<MenuItemView>(menu_item_view2));
menu_runner2->RunMenuAt(
owner(), nullptr, gfx::Rect(), MenuAnchorPosition::kTopLeft,
ui::mojom::MenuSourceType::kNone, MenuRunner::FOR_DROP, nullptr);
ui::mojom::MenuSourceType::kNone, MenuRunner::FOR_DROP);
EXPECT_NE(menu_controller.controller(), MenuController::GetActiveInstance());
menu_controller.SetShowing(true);
@ -791,7 +791,7 @@ TEST_F(MenuRunnerDestructionTest, MenuRunnerDestroyedDuringReleaseRef) {
new internal::MenuRunnerImpl(CreateMenuItemView());
menu_runner->RunMenuAt(owner(), nullptr, gfx::Rect(),
MenuAnchorPosition::kTopLeft,
ui::mojom::MenuSourceType::kNone, 0, nullptr);
ui::mojom::MenuSourceType::kNone, 0);
base::RunLoop run_loop;
static_cast<ReleaseRefTestViewsDelegate*>(test_views_delegate())
@ -943,8 +943,8 @@ TEST_F(MenuRunnerTest, ShowMenuHostDurationMetricsDoesLog) {
InitMenuRunner(0);
MenuRunner* runner = menu_runner();
runner->RunMenuAt(owner(), nullptr, gfx::Rect(), MenuAnchorPosition::kTopLeft,
ui::mojom::MenuSourceType::kNone, nullptr, std::nullopt,
histogram_name);
ui::mojom::MenuSourceType::kNone, gfx::NativeView(),
std::nullopt, histogram_name);
base::RunLoop run_loop;
views::MenuController::GetActiveInstance()
@ -974,7 +974,7 @@ TEST_F(MenuRunnerTest, ShowMenuHostDurationMetricsDoesNotLog) {
InitMenuRunner(0);
MenuRunner* runner = menu_runner();
runner->RunMenuAt(owner(), nullptr, gfx::Rect(), MenuAnchorPosition::kTopLeft,
ui::mojom::MenuSourceType::kNone, nullptr, std::nullopt);
ui::mojom::MenuSourceType::kNone);
base::RunLoop run_loop;
views::MenuController::GetActiveInstance()

@ -12,6 +12,7 @@
#include "ui/base/cursor/cursor.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/controls/native/native_view_host_wrapper.h"
#include "ui/views/painter.h"
#include "ui/views/view_utils.h"
@ -94,7 +95,8 @@ void NativeViewHost::SetNativeViewSize(const gfx::Size& size) {
}
gfx::NativeView NativeViewHost::GetNativeViewContainer() const {
return native_view_ ? native_wrapper_->GetNativeViewContainer() : nullptr;
return native_view_ ? native_wrapper_->GetNativeViewContainer()
: gfx::NativeView();
}
void NativeViewHost::NativeViewDestroyed() {
@ -287,7 +289,7 @@ void NativeViewHost::Detach(bool destroyed) {
ClearFocus();
}
native_wrapper_->NativeViewDetaching(destroyed);
native_view_ = nullptr;
native_view_ = gfx::NativeView();
}
}

@ -297,7 +297,7 @@ void NativeViewHostMac::SetFocus() {
gfx::NativeView NativeViewHostMac::GetNativeViewContainer() const {
NOTIMPLEMENTED();
return nullptr;
return gfx::NativeView();
}
gfx::NativeViewAccessible NativeViewHostMac::GetNativeViewAccessible() {

@ -21,6 +21,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/mojom/ui_base_types.mojom-shared.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/test/view_metadata_test_utils.h"
#include "ui/views/test/widget_test.h"
@ -91,8 +92,8 @@ class WebDialogViewUnitTest : public views::test::WidgetTest {
// views code and the location of TestingProfile.
web_dialog_view_->disable_url_load_for_test_ = true;
widget_ = views::DialogDelegate::CreateDialogWidget(web_dialog_view_,
GetContext(), nullptr);
widget_ = views::DialogDelegate::CreateDialogWidget(
web_dialog_view_, GetContext(), gfx::NativeView());
widget_->Show();
EXPECT_FALSE(widget_is_closed());
}

@ -25,7 +25,8 @@ std::unique_ptr<EventMonitor> EventMonitor::CreateApplicationMonitor(
gfx::NativeWindow context,
const std::set<ui::EventType>& types) {
// |context| is not needed on Mac.
return std::make_unique<EventMonitorMac>(event_observer, nullptr, types);
return std::make_unique<EventMonitorMac>(event_observer, gfx::NativeWindow(),
types);
}
// static

@ -15,6 +15,7 @@
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/base/mojom/ui_base_types.mojom-shared.h"
#include "ui/base/ui_base_types.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/vector_icon_types.h"
#include "ui/views/accessibility/view_accessibility.h"
@ -163,7 +164,7 @@ void ColoredDialogChooser::ButtonPressed() {
views::Widget* widget = DialogDelegate::CreateDialogWidget(
new ColoredDialog(base::BindOnce(&ColoredDialogChooser::OnFeedbackSubmit,
base::Unretained(this))),
nullptr, GetWidget()->GetNativeView());
gfx::NativeWindow(), GetWidget()->GetNativeView());
widget->Show();
}

@ -12,6 +12,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/mojom/ui_base_types.mojom-shared.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/background.h"
#include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/label.h"
@ -84,7 +85,7 @@ void WidgetExample::CreateDialogWidget(View* sender, bool modal) {
if (modal) {
dialog->SetModalType(ui::mojom::ModalType::kWindow);
}
DialogDelegate::CreateDialogWidget(dialog.release(), nullptr,
DialogDelegate::CreateDialogWidget(dialog.release(), gfx::NativeWindow(),
sender->GetWidget()->GetNativeView())
->Show();
}

@ -8,6 +8,7 @@
#include "base/functional/bind.h"
#include "base/logging.h"
#include "ui/gfx/native_widget_types.h"
namespace views::test {
@ -74,7 +75,7 @@ WidgetFocusObserver::~WidgetFocusObserver() = default;
gfx::NativeView WidgetFocusObserver::GetStateObserverInitialState() const {
auto* const widget =
internal::WidgetFocusSupplierFrame::GetCurrentFrame()->GetActiveWidget();
return widget ? widget->GetNativeView() : nullptr;
return widget ? widget->GetNativeView() : gfx::NativeView();
}
void WidgetFocusObserver::OnWidgetFocusChanged(gfx::NativeView focused_now) {

@ -26,7 +26,7 @@ void ViewsTestHelper::TearDownTestViewsDelegate(TestViewsDelegate* delegate) {}
void ViewsTestHelper::SetUp() {}
gfx::NativeWindow ViewsTestHelper::GetContext() {
return nullptr;
return gfx::NativeWindow();
}
} // namespace views

@ -1908,7 +1908,7 @@ TEST_F(NativeWidgetMacTest, NativeProperties) {
// Create a dialog widget (also TYPE_WINDOW), but with a DialogDelegate.
Widget* dialog_widget = views::DialogDelegate::CreateDialogWidget(
MakeModalDialog(ui::mojom::ModalType::kChild), nullptr,
MakeModalDialog(ui::mojom::ModalType::kChild), gfx::NativeWindow(),
regular_widget->GetNativeView());
EXPECT_TRUE([dialog_widget->GetNativeWindow().GetNativeNSWindow()
canBecomeKeyWindow]);
@ -2458,7 +2458,8 @@ NSArray* ExtractTouchBarGroupIdentifiers(NSView* view) {
// Test TouchBar integration.
TEST_F(NativeWidgetMacTest, TouchBar) {
DialogDelegate* delegate = MakeModalDialog(ui::mojom::ModalType::kNone);
views::DialogDelegate::CreateDialogWidget(delegate, nullptr, nullptr);
views::DialogDelegate::CreateDialogWidget(delegate, gfx::NativeWindow(),
gfx::NativeView());
NSView* content =
[delegate->GetWidget()->GetNativeWindow().GetNativeNSWindow()
contentView];

@ -21,6 +21,7 @@
#include "ui/base/mojom/menu_source_type.mojom.h"
#include "ui/events/event_utils.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/context_menu_controller.h"
#include "ui/views/test/ax_event_counter.h"
@ -904,8 +905,8 @@ class RootViewTestDialogDelegate : public DialogDelegateView {
// happens at the ContentView's preferred size.
TEST_F(RootViewTest, SingleLayoutDuringInit) {
RootViewTestDialogDelegate* delegate = new RootViewTestDialogDelegate();
Widget* widget =
DialogDelegate::CreateDialogWidget(delegate, GetContext(), nullptr);
Widget* widget = DialogDelegate::CreateDialogWidget(delegate, GetContext(),
gfx::NativeView());
EXPECT_EQ(1, delegate->layout_count());
widget->CloseNow();
}
@ -915,8 +916,8 @@ using RootViewDesktopNativeWidgetTest = ViewsTestWithDesktopNativeWidget;
// Also test Aura desktop Widget codepaths.
TEST_F(RootViewDesktopNativeWidgetTest, SingleLayoutDuringInit) {
RootViewTestDialogDelegate* delegate = new RootViewTestDialogDelegate();
Widget* widget =
DialogDelegate::CreateDialogWidget(delegate, GetContext(), nullptr);
Widget* widget = DialogDelegate::CreateDialogWidget(delegate, GetContext(),
gfx::NativeView());
EXPECT_EQ(1, delegate->layout_count());
widget->CloseNow();
}

@ -1870,7 +1870,7 @@ void Widget::OnNativeFocus() {
}
void Widget::OnNativeBlur() {
WidgetFocusManager::GetInstance()->OnNativeFocusChanged(nullptr);
WidgetFocusManager::GetInstance()->OnNativeFocusChanged(gfx::NativeView());
}
void Widget::OnNativeWidgetVisibilityChanged(bool visible) {

@ -1110,7 +1110,8 @@ TEST_F(DesktopWidgetTestInteractive, WindowModalWindowDestroyedActivationTest) {
dialog_delegate->SetModalType(ui::mojom::ModalType::kWindow);
Widget* modal_dialog_widget = views::DialogDelegate::CreateDialogWidget(
dialog_delegate.release(), nullptr, top_level_widget->GetNativeView());
dialog_delegate.release(), gfx::NativeWindow(),
top_level_widget->GetNativeView());
modal_dialog_widget->SetBounds(gfx::Rect(100, 100, 200, 200));
// Note the dialog widget doesn't need a ShowSync. Since it is modal, it gains
@ -2134,7 +2135,8 @@ TEST_F(WidgetCaptureTest, MAYBE_SystemModalWindowReleasesCapture) {
dialog_delegate->SetModalType(ui::mojom::ModalType::kSystem);
Widget* modal_dialog_widget = views::DialogDelegate::CreateDialogWidget(
dialog_delegate.release(), nullptr, top_level_widget->GetNativeView());
dialog_delegate.release(), gfx::NativeWindow(),
top_level_widget->GetNativeView());
modal_dialog_widget->SetBounds(gfx::Rect(100, 100, 200, 200));
ShowSync(modal_dialog_widget);

@ -1797,7 +1797,7 @@ TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, OnNativeWidgetPaint) {
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
OnNativeWidgetParentChanged) {
widget()->OnNativeWidgetParentChanged(nullptr);
widget()->OnNativeWidgetParentChanged(gfx::NativeView());
}
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
@ -1916,7 +1916,7 @@ TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, ReorderNativeViews) {
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, ReparentNativeView) {
EXPECT_DCHECK_DEATH(
Widget::ReparentNativeView(widget()->GetNativeView(), nullptr));
Widget::ReparentNativeView(widget()->GetNativeView(), gfx::NativeView()));
}
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, Restore) {

@ -15,6 +15,7 @@
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/base/mojom/window_show_state.mojom.h"
#include "ui/events/event_processor.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/bubble/bubble_border.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/button/checkbox.h"
@ -550,8 +551,8 @@ TEST_F(DialogDelegateCloseTest, OldClosePathDoesNotDoubleClose) {
auto dialog_owned =
std::make_unique<TestDialogDelegateView>(&accepted, &cancelled);
TestDialogDelegateView* dialog = dialog_owned.get();
Widget* widget = DialogDelegate::CreateDialogWidget(std::move(dialog_owned),
GetContext(), nullptr);
Widget* widget = DialogDelegate::CreateDialogWidget(
std::move(dialog_owned), GetContext(), gfx::NativeView());
widget->Show();
views::test::WidgetDestroyedWaiter destroyed_waiter(widget);