| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" | 5 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser_shutdown.h" | 7 #include "chrome/browser/browser_shutdown.h" |
| 8 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" | 8 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" |
| 9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 10 #include "content/public/browser/web_contents_view.h" | 10 #include "content/public/browser/web_contents_view.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 EnforceMaxTextSize(message_text, &message_text_); | 77 EnforceMaxTextSize(message_text, &message_text_); |
| 78 EnforceMaxPromptSize(default_prompt_text, &default_prompt_text_); | 78 EnforceMaxPromptSize(default_prompt_text, &default_prompt_text_); |
| 79 } | 79 } |
| 80 | 80 |
| 81 JavaScriptAppModalDialog::~JavaScriptAppModalDialog() { | 81 JavaScriptAppModalDialog::~JavaScriptAppModalDialog() { |
| 82 } | 82 } |
| 83 | 83 |
| 84 NativeAppModalDialog* JavaScriptAppModalDialog::CreateNativeDialog() { | 84 NativeAppModalDialog* JavaScriptAppModalDialog::CreateNativeDialog() { |
| 85 gfx::NativeWindow parent_window = | 85 gfx::NativeWindow parent_window = |
| 86 web_contents()->GetView()->GetTopLevelNativeWindow(); | 86 web_contents()->GetView()->GetTopLevelNativeWindow(); |
| 87 #if defined(USE_AURA) | 87 #if defined(USE_AURA) && defined(OS_WIN) |
| 88 if (!parent_window->GetRootWindow()) { | 88 // Javascript dialogs should be top-level windows in desktop WinAura. |
| 89 // When we are part of a WebContents that isn't actually being displayed on | 89 parent_window = NULL; |
| 90 // the screen, we can't actually attach to it. | |
| 91 parent_window = NULL; | |
| 92 } | |
| 93 #endif | 90 #endif |
| 94 return NativeAppModalDialog::CreateNativeJavaScriptPrompt(this, | 91 return NativeAppModalDialog::CreateNativeJavaScriptPrompt(this, |
| 95 parent_window); | 92 parent_window); |
| 96 } | 93 } |
| 97 | 94 |
| 98 bool JavaScriptAppModalDialog::IsJavaScriptModalDialog() { | 95 bool JavaScriptAppModalDialog::IsJavaScriptModalDialog() { |
| 99 return true; | 96 return true; |
| 100 } | 97 } |
| 101 | 98 |
| 102 void JavaScriptAppModalDialog::Invalidate() { | 99 void JavaScriptAppModalDialog::Invalidate() { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 152 |
| 156 callback_.Run(success, user_input); | 153 callback_.Run(success, user_input); |
| 157 | 154 |
| 158 extra_data_->last_javascript_message_dismissal_ = base::TimeTicks::Now(); | 155 extra_data_->last_javascript_message_dismissal_ = base::TimeTicks::Now(); |
| 159 extra_data_->suppress_javascript_messages_ = suppress_js_messages; | 156 extra_data_->suppress_javascript_messages_ = suppress_js_messages; |
| 160 | 157 |
| 161 // On Views, we can end up coming through this code path twice :(. | 158 // On Views, we can end up coming through this code path twice :(. |
| 162 // See crbug.com/63732. | 159 // See crbug.com/63732. |
| 163 valid_ = false; | 160 valid_ = false; |
| 164 } | 161 } |
| OLD | NEW |