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" |
11 #include "ui/base/text/text_elider.h" | 11 #include "ui/base/text/text_elider.h" |
12 | 12 |
13 #if defined(USE_AURA) | |
14 #include "ui/aura/root_window.h" | |
15 #endif | |
16 | |
13 using content::JavaScriptDialogCreator; | 17 using content::JavaScriptDialogCreator; |
14 using content::WebContents; | 18 using content::WebContents; |
15 | 19 |
16 namespace { | 20 namespace { |
17 | 21 |
18 // Control maximum sizes of various texts passed to us from javascript. | 22 // Control maximum sizes of various texts passed to us from javascript. |
19 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 23 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
20 // Two-dimensional eliding. Reformat the text of the message dialog | 24 // Two-dimensional eliding. Reformat the text of the message dialog |
21 // inserting line breaks because otherwise a single long line can overflow | 25 // inserting line breaks because otherwise a single long line can overflow |
22 // the message dialog (and crash/hang the GTK, depending on the version). | 26 // the message dialog (and crash/hang the GTK, depending on the version). |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 EnforceMaxTextSize(message_text, &message_text_); | 77 EnforceMaxTextSize(message_text, &message_text_); |
74 EnforceMaxPromptSize(default_prompt_text, &default_prompt_text_); | 78 EnforceMaxPromptSize(default_prompt_text, &default_prompt_text_); |
75 } | 79 } |
76 | 80 |
77 JavaScriptAppModalDialog::~JavaScriptAppModalDialog() { | 81 JavaScriptAppModalDialog::~JavaScriptAppModalDialog() { |
78 } | 82 } |
79 | 83 |
80 NativeAppModalDialog* JavaScriptAppModalDialog::CreateNativeDialog() { | 84 NativeAppModalDialog* JavaScriptAppModalDialog::CreateNativeDialog() { |
81 gfx::NativeWindow parent_window = | 85 gfx::NativeWindow parent_window = |
82 web_contents()->GetView()->GetTopLevelNativeWindow(); | 86 web_contents()->GetView()->GetTopLevelNativeWindow(); |
87 #if defined(USE_AURA) | |
88 if (!parent_window->GetRootWindow()) { | |
89 // When we are part of a WebContents that isn't actually being displayed on | |
Ben Goodger (Google)
2013/01/15 18:19:52
Does this happen when a js alert happens before a
Elliot Glaysher
2013/01/15 19:27:51
Which hidden root window? AFAIK, there never was o
| |
90 // the screen, we can't actually attach to it. | |
91 parent_window = NULL; | |
92 } | |
93 #endif | |
83 return NativeAppModalDialog::CreateNativeJavaScriptPrompt(this, | 94 return NativeAppModalDialog::CreateNativeJavaScriptPrompt(this, |
84 parent_window); | 95 parent_window); |
85 } | 96 } |
86 | 97 |
87 bool JavaScriptAppModalDialog::IsJavaScriptModalDialog() { | 98 bool JavaScriptAppModalDialog::IsJavaScriptModalDialog() { |
88 return true; | 99 return true; |
89 } | 100 } |
90 | 101 |
91 void JavaScriptAppModalDialog::Invalidate() { | 102 void JavaScriptAppModalDialog::Invalidate() { |
92 if (!valid_) | 103 if (!valid_) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 | 155 |
145 callback_.Run(success, user_input); | 156 callback_.Run(success, user_input); |
146 | 157 |
147 extra_data_->last_javascript_message_dismissal_ = base::TimeTicks::Now(); | 158 extra_data_->last_javascript_message_dismissal_ = base::TimeTicks::Now(); |
148 extra_data_->suppress_javascript_messages_ = suppress_js_messages; | 159 extra_data_->suppress_javascript_messages_ = suppress_js_messages; |
149 | 160 |
150 // On Views, we can end up coming through this code path twice :(. | 161 // On Views, we can end up coming through this code path twice :(. |
151 // See crbug.com/63732. | 162 // See crbug.com/63732. |
152 valid_ = false; | 163 valid_ = false; |
153 } | 164 } |
OLD | NEW |