Refactor NativeWindow (Part 3): Remove is_offscreen_dummy from NativeWindow (#12503)

* Don't use is_offscreen_dummy in MessageBox

* Don't use is_offscreen_dummy in DownloadManagerDelegate

* Don't use is_offscreen_dummy in CommonWebContentsDelegate

* Remove is_offscreen_dummy from NativeWindow
This commit is contained in:
Cheng Zhao 2018-04-03 12:19:35 +09:00 committed by GitHub
parent 1a649a6ac3
commit 8fc5c6c862
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 34 additions and 29 deletions

View file

@ -55,19 +55,25 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
origin_counts_[origin]++;
auto* web_preferences = WebContentsPreferences::From(web_contents);
std::string checkbox;
if (origin_counts_[origin] > 1) {
auto* web_preferences = WebContentsPreferences::From(web_contents);
if (web_preferences &&
web_preferences->IsEnabled("safeDialogs") &&
!web_preferences->dict()->GetString("safeDialogsMessage", &checkbox)) {
checkbox = "Prevent this app from creating additional dialogs";
}
if (origin_counts_[origin] > 1 &&
web_preferences &&
web_preferences->IsEnabled("safeDialogs") &&
!web_preferences->dict()->GetString("safeDialogsMessage", &checkbox)) {
checkbox = "Prevent this app from creating additional dialogs";
}
// Don't set parent for offscreen window.
NativeWindow* window = nullptr;
if (web_preferences && !web_preferences->IsEnabled("offscreen")) {
auto* relay = NativeWindowRelay::FromWebContents(web_contents);
if (relay)
window = relay->window.get();
}
auto* relay = NativeWindowRelay::FromWebContents(web_contents);
atom::ShowMessageBox(
relay ? relay->window.get() : nullptr,
window,
atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, -1, 0,
atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
base::UTF16ToUTF8(message_text), "", checkbox,