Commit 23980598 authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

Don't crash if user attempts file selection against policy

If the user attempts to open a file selection dialog but
they are disabled by policy, the policy code attempts to
show a warning infobar.

Do not crash in the case where it is not possible to show
an infobar.

Fixed: 1137482
Change-Id: I64c02a42e8c84293e73ec3eefb3d72323c933a6f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2469256
Commit-Queue: Avi Drissman <avi@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816837}
parent 5db7b125
......@@ -27,15 +27,18 @@ bool ChromeSelectFilePolicy::CanOpenSelectFileDialog() {
}
void ChromeSelectFilePolicy::SelectFileDenied() {
// Show the InfoBar saying that file-selection dialogs are disabled.
// If the WebContents is in a browser window, show an infobar saying that
// file selection dialogs are disabled.
if (source_contents_) {
SimpleAlertInfoBarDelegate::Create(
InfoBarService::FromWebContents(source_contents_),
infobars::InfoBarDelegate::FILE_ACCESS_DISABLED_INFOBAR_DELEGATE,
nullptr, l10n_util::GetStringUTF16(IDS_FILE_SELECTION_DIALOG_INFOBAR));
} else {
LOG(WARNING) << "File-selection dialogs are disabled but no WebContents "
<< "is given to display the InfoBar.";
InfoBarService* infobar_service =
InfoBarService::FromWebContents(source_contents_);
if (infobar_service) {
SimpleAlertInfoBarDelegate::Create(
infobar_service,
infobars::InfoBarDelegate::FILE_ACCESS_DISABLED_INFOBAR_DELEGATE,
nullptr,
l10n_util::GetStringUTF16(IDS_FILE_SELECTION_DIALOG_INFOBAR));
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment