| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/browser_shutdown.h" | 8 #include "chrome/browser/browser_shutdown.h" |
| 9 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" | 9 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" |
| 10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| 11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
| 12 #include "content/public/browser/web_contents_view.h" | 12 #include "content/public/browser/web_contents_view.h" |
| 13 #include "ui/base/text/text_elider.h" | 13 #include "ui/gfx/text_elider.h" |
| 14 | 14 |
| 15 #if defined(USE_AURA) | 15 #if defined(USE_AURA) |
| 16 #include "ui/aura/root_window.h" | 16 #include "ui/aura/root_window.h" |
| 17 #endif | 17 #endif |
| 18 | 18 |
| 19 using content::JavaScriptDialogManager; | 19 using content::JavaScriptDialogManager; |
| 20 using content::WebContents; | 20 using content::WebContents; |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // Control maximum sizes of various texts passed to us from javascript. | 24 // Control maximum sizes of various texts passed to us from javascript. |
| 25 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 25 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 26 // Two-dimensional eliding. Reformat the text of the message dialog | 26 // Two-dimensional eliding. Reformat the text of the message dialog |
| 27 // inserting line breaks because otherwise a single long line can overflow | 27 // inserting line breaks because otherwise a single long line can overflow |
| 28 // the message dialog (and crash/hang the GTK, depending on the version). | 28 // the message dialog (and crash/hang the GTK, depending on the version). |
| 29 const int kMessageTextMaxRows = 32; | 29 const int kMessageTextMaxRows = 32; |
| 30 const int kMessageTextMaxCols = 132; | 30 const int kMessageTextMaxCols = 132; |
| 31 const int kDefaultPromptMaxRows = 24; | 31 const int kDefaultPromptMaxRows = 24; |
| 32 const int kDefaultPromptMaxCols = 132; | 32 const int kDefaultPromptMaxCols = 132; |
| 33 void EnforceMaxTextSize(const string16& in_string, string16* out_string) { | 33 void EnforceMaxTextSize(const string16& in_string, string16* out_string) { |
| 34 ui::ElideRectangleString(in_string, kMessageTextMaxRows, | 34 gfx::ElideRectangleString(in_string, kMessageTextMaxRows, |
| 35 kMessageTextMaxCols, false, out_string); | 35 kMessageTextMaxCols, false, out_string); |
| 36 } | 36 } |
| 37 void EnforceMaxPromptSize(const string16& in_string, string16* out_string) { | 37 void EnforceMaxPromptSize(const string16& in_string, string16* out_string) { |
| 38 ui::ElideRectangleString(in_string, kDefaultPromptMaxRows, | 38 gfx::ElideRectangleString(in_string, kDefaultPromptMaxRows, |
| 39 kDefaultPromptMaxCols, false, out_string); | 39 kDefaultPromptMaxCols, false, out_string); |
| 40 } | 40 } |
| 41 #else | 41 #else |
| 42 // One-dimensional eliding. Trust the window system to break the string | 42 // One-dimensional eliding. Trust the window system to break the string |
| 43 // appropriately, but limit its overall length to something reasonable. | 43 // appropriately, but limit its overall length to something reasonable. |
| 44 const int kMessageTextMaxSize = 3000; | 44 const int kMessageTextMaxSize = 3000; |
| 45 const int kDefaultPromptMaxSize = 2000; | 45 const int kDefaultPromptMaxSize = 2000; |
| 46 void EnforceMaxTextSize(const string16& in_string, string16* out_string) { | 46 void EnforceMaxTextSize(const string16& in_string, string16* out_string) { |
| 47 ui::ElideString(in_string, kMessageTextMaxSize, out_string); | 47 gfx::ElideString(in_string, kMessageTextMaxSize, out_string); |
| 48 } | 48 } |
| 49 void EnforceMaxPromptSize(const string16& in_string, string16* out_string) { | 49 void EnforceMaxPromptSize(const string16& in_string, string16* out_string) { |
| 50 ui::ElideString(in_string, kDefaultPromptMaxSize, out_string); | 50 gfx::ElideString(in_string, kDefaultPromptMaxSize, out_string); |
| 51 } | 51 } |
| 52 #endif | 52 #endif |
| 53 | 53 |
| 54 } // namespace | 54 } // namespace |
| 55 | 55 |
| 56 ChromeJavaScriptDialogExtraData::ChromeJavaScriptDialogExtraData() | 56 ChromeJavaScriptDialogExtraData::ChromeJavaScriptDialogExtraData() |
| 57 : suppress_javascript_messages_(false) { | 57 : suppress_javascript_messages_(false) { |
| 58 } | 58 } |
| 59 | 59 |
| 60 JavaScriptAppModalDialog::JavaScriptAppModalDialog( | 60 JavaScriptAppModalDialog::JavaScriptAppModalDialog( |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 if (extra_data != extra_data_map_->end()) { | 170 if (extra_data != extra_data_map_->end()) { |
| 171 extra_data->second.last_javascript_message_dismissal_ = | 171 extra_data->second.last_javascript_message_dismissal_ = |
| 172 base::TimeTicks::Now(); | 172 base::TimeTicks::Now(); |
| 173 extra_data->second.suppress_javascript_messages_ = suppress_js_messages; | 173 extra_data->second.suppress_javascript_messages_ = suppress_js_messages; |
| 174 } | 174 } |
| 175 | 175 |
| 176 // On Views, we can end up coming through this code path twice :(. | 176 // On Views, we can end up coming through this code path twice :(. |
| 177 // See crbug.com/63732. | 177 // See crbug.com/63732. |
| 178 AppModalDialog::Invalidate(); | 178 AppModalDialog::Invalidate(); |
| 179 } | 179 } |
| OLD | NEW |