refactor: eliminate duplicate code (#40088)
This commit is contained in:
parent
cff50ac65a
commit
6a99c7b840
2 changed files with 14 additions and 19 deletions
|
@ -101,14 +101,7 @@ void FileSelectHelper::FileSelectedWithExtraInfo(
|
||||||
std::vector<ui::SelectedFileInfo> files;
|
std::vector<ui::SelectedFileInfo> files;
|
||||||
files.push_back(file);
|
files.push_back(file);
|
||||||
|
|
||||||
#if BUILDFLAG(IS_MAC)
|
MultiFilesSelectedWithExtraInfo(files, params);
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileSelectHelper::MultiFilesSelected(
|
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
|
} // namespace
|
||||||
|
|
||||||
NativeWindowMac::NativeWindowMac(const gin_helper::Dictionary& options,
|
NativeWindowMac::NativeWindowMac(const gin_helper::Dictionary& options,
|
||||||
|
@ -1256,10 +1264,7 @@ void NativeWindowMac::AddBrowserView(NativeBrowserView* view) {
|
||||||
}
|
}
|
||||||
|
|
||||||
add_browser_view(view);
|
add_browser_view(view);
|
||||||
if (view->GetInspectableWebContentsView()) {
|
if (auto* native_view = GetNativeNSView(view)) {
|
||||||
auto* native_view = view->GetInspectableWebContentsView()
|
|
||||||
->GetNativeView()
|
|
||||||
.GetNativeNSView();
|
|
||||||
[[window_ contentView] addSubview:native_view
|
[[window_ contentView] addSubview:native_view
|
||||||
positioned:NSWindowAbove
|
positioned:NSWindowAbove
|
||||||
relativeTo:nil];
|
relativeTo:nil];
|
||||||
|
@ -1278,9 +1283,9 @@ void NativeWindowMac::RemoveBrowserView(NativeBrowserView* view) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view->GetInspectableWebContentsView())
|
if (auto* native_view = GetNativeNSView(view)) {
|
||||||
[view->GetInspectableWebContentsView()->GetNativeView().GetNativeNSView()
|
[native_view removeFromSuperview];
|
||||||
removeFromSuperview];
|
}
|
||||||
remove_browser_view(view);
|
remove_browser_view(view);
|
||||||
|
|
||||||
[CATransaction commit];
|
[CATransaction commit];
|
||||||
|
@ -1297,10 +1302,7 @@ void NativeWindowMac::SetTopBrowserView(NativeBrowserView* view) {
|
||||||
|
|
||||||
remove_browser_view(view);
|
remove_browser_view(view);
|
||||||
add_browser_view(view);
|
add_browser_view(view);
|
||||||
if (view->GetInspectableWebContentsView()) {
|
if (auto* native_view = GetNativeNSView(view)) {
|
||||||
auto* native_view = view->GetInspectableWebContentsView()
|
|
||||||
->GetNativeView()
|
|
||||||
.GetNativeNSView();
|
|
||||||
[[window_ contentView] addSubview:native_view
|
[[window_ contentView] addSubview:native_view
|
||||||
positioned:NSWindowAbove
|
positioned:NSWindowAbove
|
||||||
relativeTo:nil];
|
relativeTo:nil];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue