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 |
87 #if defined(USE_AURA) | 88 #if defined(USE_AURA) |
| 89 #if defined(OS_WIN) |
| 90 // JS dialogs should always be top-level windows in desktop Aura on Windows. |
| 91 parent_window = NULL; |
| 92 #else |
88 if (!parent_window->GetRootWindow()) { | 93 if (!parent_window->GetRootWindow()) { |
89 // When we are part of a WebContents that isn't actually being displayed on | 94 // When we are part of a WebContents that isn't actually being displayed on |
90 // the screen, we can't actually attach to it. | 95 // the screen, we can't actually attach to it. |
91 parent_window = NULL; | 96 parent_window = NULL; |
92 } | 97 } |
93 #endif | 98 #endif // defined(OS_WIN) |
| 99 #endif // defined(USE_AURA) |
| 100 |
94 return NativeAppModalDialog::CreateNativeJavaScriptPrompt(this, | 101 return NativeAppModalDialog::CreateNativeJavaScriptPrompt(this, |
95 parent_window); | 102 parent_window); |
96 } | 103 } |
97 | 104 |
98 bool JavaScriptAppModalDialog::IsJavaScriptModalDialog() { | 105 bool JavaScriptAppModalDialog::IsJavaScriptModalDialog() { |
99 return true; | 106 return true; |
100 } | 107 } |
101 | 108 |
102 void JavaScriptAppModalDialog::Invalidate() { | 109 void JavaScriptAppModalDialog::Invalidate() { |
103 if (!valid_) | 110 if (!valid_) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 162 |
156 callback_.Run(success, user_input); | 163 callback_.Run(success, user_input); |
157 | 164 |
158 extra_data_->last_javascript_message_dismissal_ = base::TimeTicks::Now(); | 165 extra_data_->last_javascript_message_dismissal_ = base::TimeTicks::Now(); |
159 extra_data_->suppress_javascript_messages_ = suppress_js_messages; | 166 extra_data_->suppress_javascript_messages_ = suppress_js_messages; |
160 | 167 |
161 // On Views, we can end up coming through this code path twice :(. | 168 // On Views, we can end up coming through this code path twice :(. |
162 // See crbug.com/63732. | 169 // See crbug.com/63732. |
163 valid_ = false; | 170 valid_ = false; |
164 } | 171 } |
OLD | NEW |