Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: chrome/browser/ui/app_modal_dialogs/js_modal_dialog.cc

Issue 6257006: Move a bunch of random other files to src/ui/base... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/js_modal_dialog.h" 5 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h"
6 6
7 #include "app/text_elider.h"
8 #include "base/string_util.h" 7 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/browser_shutdown.h" 9 #include "chrome/browser/browser_shutdown.h"
11 #include "chrome/browser/extensions/extension_host.h" 10 #include "chrome/browser/extensions/extension_host.h"
12 #include "chrome/browser/tab_contents/tab_contents.h" 11 #include "chrome/browser/tab_contents/tab_contents.h"
13 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" 12 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h"
14 #include "chrome/common/notification_service.h" 13 #include "chrome/common/notification_service.h"
15 #include "chrome/common/notification_type.h" 14 #include "chrome/common/notification_type.h"
16 #include "ipc/ipc_message.h" 15 #include "ipc/ipc_message.h"
16 #include "ui/base/text/text_elider.h"
17 17
18 namespace { 18 namespace {
19 19
20 // The maximum sizes of various texts passed to us from javascript. 20 // The maximum sizes of various texts passed to us from javascript.
21 const int kMessageTextMaxRows = 32; 21 const int kMessageTextMaxRows = 32;
22 const int kMessageTextMaxCols = 132; 22 const int kMessageTextMaxCols = 132;
23 const int kDefaultPromptTextSize = 2000; 23 const int kDefaultPromptTextSize = 2000;
24 24
25 } // namespace 25 } // namespace
26 26
27 JavaScriptAppModalDialog::JavaScriptAppModalDialog( 27 JavaScriptAppModalDialog::JavaScriptAppModalDialog(
28 JavaScriptAppModalDialogDelegate* delegate, 28 JavaScriptAppModalDialogDelegate* delegate,
29 const std::wstring& title, 29 const std::wstring& title,
30 int dialog_flags, 30 int dialog_flags,
31 const std::wstring& message_text, 31 const std::wstring& message_text,
32 const std::wstring& default_prompt_text, 32 const std::wstring& default_prompt_text,
33 bool display_suppress_checkbox, 33 bool display_suppress_checkbox,
34 bool is_before_unload_dialog, 34 bool is_before_unload_dialog,
35 IPC::Message* reply_msg) 35 IPC::Message* reply_msg)
36 : AppModalDialog(delegate->AsTabContents(), title), 36 : AppModalDialog(delegate->AsTabContents(), title),
37 delegate_(delegate), 37 delegate_(delegate),
38 extension_host_(delegate->AsExtensionHost()), 38 extension_host_(delegate->AsExtensionHost()),
39 dialog_flags_(dialog_flags), 39 dialog_flags_(dialog_flags),
40 display_suppress_checkbox_(display_suppress_checkbox), 40 display_suppress_checkbox_(display_suppress_checkbox),
41 is_before_unload_dialog_(is_before_unload_dialog), 41 is_before_unload_dialog_(is_before_unload_dialog),
42 reply_msg_(reply_msg) { 42 reply_msg_(reply_msg) {
43 // We trim the various parts of the message dialog because otherwise we can 43 // We trim the various parts of the message dialog because otherwise we can
44 // overflow the message dialog (and crash/hang the GTK+ version). 44 // overflow the message dialog (and crash/hang the GTK+ version).
45 string16 elided_text; 45 string16 elided_text;
46 gfx::ElideRectangleString(WideToUTF16(message_text), 46 ui::ElideRectangleString(WideToUTF16(message_text),
47 kMessageTextMaxRows, kMessageTextMaxCols, &elided_text); 47 kMessageTextMaxRows, kMessageTextMaxCols, &elided_text);
48 message_text_ = UTF16ToWide(elided_text); 48 message_text_ = UTF16ToWide(elided_text);
49 gfx::ElideString(default_prompt_text, kDefaultPromptTextSize, 49 ui::ElideString(default_prompt_text, kDefaultPromptTextSize,
50 &default_prompt_text_); 50 &default_prompt_text_);
51 51
52 DCHECK((tab_contents_ != NULL) != (extension_host_ != NULL)); 52 DCHECK((tab_contents_ != NULL) != (extension_host_ != NULL));
53 InitNotifications(); 53 InitNotifications();
54 } 54 }
55 55
56 JavaScriptAppModalDialog::~JavaScriptAppModalDialog() { 56 JavaScriptAppModalDialog::~JavaScriptAppModalDialog() {
57 } 57 }
58 58
59 NativeAppModalDialog* JavaScriptAppModalDialog::CreateNativeDialog() { 59 NativeAppModalDialog* JavaScriptAppModalDialog::CreateNativeDialog() {
60 gfx::NativeWindow parent_window = tab_contents_ ? 60 gfx::NativeWindow parent_window = tab_contents_ ?
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 return; 136 return;
137 137
138 delegate_->OnMessageBoxClosed(reply_msg_, success, prompt_text); 138 delegate_->OnMessageBoxClosed(reply_msg_, success, prompt_text);
139 if (suppress_js_messages) 139 if (suppress_js_messages)
140 delegate_->SetSuppressMessageBoxes(true); 140 delegate_->SetSuppressMessageBoxes(true);
141 141
142 // On Views, we can end up coming through this code path twice :(. 142 // On Views, we can end up coming through this code path twice :(.
143 // See crbug.com/63732. 143 // See crbug.com/63732.
144 skip_this_dialog_ = true; 144 skip_this_dialog_ = true;
145 } 145 }
OLDNEW
« no previous file with comments | « chrome/browser/themes/browser_theme_provider.h ('k') | chrome/browser/ui/app_modal_dialogs/message_box_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698