refactor: eliminate duplicate code (#40088)

This commit is contained in:
Milan Burda 2023-10-09 01:43:50 +02:00 коммит произвёл GitHub
Родитель cff50ac65a
Коммит 6a99c7b840
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 14 добавлений и 19 удалений

Просмотреть файл

@ -101,14 +101,7 @@ void FileSelectHelper::FileSelectedWithExtraInfo(
std::vector<ui::SelectedFileInfo> files;
files.push_back(file);
#if BUILDFLAG(IS_MAC)
base::ThreadPool::PostTask(
FROM_HERE,
{base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
base::BindOnce(&FileSelectHelper::ProcessSelectedFilesMac, this, files));
#else
ConvertToFileChooserFileInfoList(files);
#endif // BUILDFLAG(IS_MAC)
MultiFilesSelectedWithExtraInfo(files, params);
}
void FileSelectHelper::MultiFilesSelected(

Просмотреть файл

@ -202,6 +202,14 @@ void ReorderChildWindowAbove(NSWindow* child_window, NSWindow* other_window) {
}
}
NSView* GetNativeNSView(NativeBrowserView* view) {
if (auto* inspectable = view->GetInspectableWebContentsView()) {
return inspectable->GetNativeView().GetNativeNSView();
} else {
return nullptr;
}
}
} // namespace
NativeWindowMac::NativeWindowMac(const gin_helper::Dictionary& options,
@ -1256,10 +1264,7 @@ void NativeWindowMac::AddBrowserView(NativeBrowserView* view) {
}
add_browser_view(view);
if (view->GetInspectableWebContentsView()) {
auto* native_view = view->GetInspectableWebContentsView()
->GetNativeView()
.GetNativeNSView();
if (auto* native_view = GetNativeNSView(view)) {
[[window_ contentView] addSubview:native_view
positioned:NSWindowAbove
relativeTo:nil];
@ -1278,9 +1283,9 @@ void NativeWindowMac::RemoveBrowserView(NativeBrowserView* view) {
return;
}
if (view->GetInspectableWebContentsView())
[view->GetInspectableWebContentsView()->GetNativeView().GetNativeNSView()
removeFromSuperview];
if (auto* native_view = GetNativeNSView(view)) {
[native_view removeFromSuperview];
}
remove_browser_view(view);
[CATransaction commit];
@ -1297,10 +1302,7 @@ void NativeWindowMac::SetTopBrowserView(NativeBrowserView* view) {
remove_browser_view(view);
add_browser_view(view);
if (view->GetInspectableWebContentsView()) {
auto* native_view = view->GetInspectableWebContentsView()
->GetNativeView()
.GetNativeNSView();
if (auto* native_view = GetNativeNSView(view)) {
[[window_ contentView] addSubview:native_view
positioned:NSWindowAbove
relativeTo:nil];