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

Side by Side Diff: chrome/browser/ui/cocoa/javascript_app_modal_dialog_cocoa.mm

Issue 140323005: Truncate the Javascript alert message if the length is too long on Mac port (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/cocoa/javascript_app_modal_dialog_cocoa.h" 5 #include "chrome/browser/ui/cocoa/javascript_app_modal_dialog_cocoa.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #import "base/mac/foundation_util.h" 11 #import "base/mac/foundation_util.h"
12 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
13 #import "chrome/browser/chrome_browser_application_mac.h" 13 #import "chrome/browser/chrome_browser_application_mac.h"
14 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" 14 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h"
15 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
16 #include "grit/ui_strings.h" 16 #include "grit/ui_strings.h"
17 #include "ui/base/l10n/l10n_util_mac.h" 17 #include "ui/base/l10n/l10n_util_mac.h"
18 #include "ui/base/ui_base_types.h" 18 #include "ui/base/ui_base_types.h"
19 19
20 const int kMessageTextMaxRows = 32;
jeremy 2014/01/21 21:24:39 This is a cross-platform limit right, WDYT about u
21
20 // Helper object that receives the notification that the dialog/sheet is 22 // Helper object that receives the notification that the dialog/sheet is
21 // going away. Is responsible for cleaning itself up. 23 // going away. Is responsible for cleaning itself up.
22 @interface JavaScriptAppModalDialogHelper : NSObject<NSAlertDelegate> { 24 @interface JavaScriptAppModalDialogHelper : NSObject<NSAlertDelegate> {
23 @private 25 @private
24 base::scoped_nsobject<NSAlert> alert_; 26 base::scoped_nsobject<NSAlert> alert_;
25 NSTextField* textField_; // WEAK; owned by alert_ 27 NSTextField* textField_; // WEAK; owned by alert_
26 } 28 }
27 29
28 - (NSAlert*)alert; 30 - (NSAlert*)alert;
29 - (NSTextField*)textField; 31 - (NSTextField*)textField;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 alert_ = [helper_ alert]; 141 alert_ = [helper_ alert];
140 NSTextField* field = nil; 142 NSTextField* field = nil;
141 if (text_field) { 143 if (text_field) {
142 field = [helper_ textField]; 144 field = [helper_ textField];
143 [field setStringValue:base::SysUTF16ToNSString( 145 [field setStringValue:base::SysUTF16ToNSString(
144 dialog_->default_prompt_text())]; 146 dialog_->default_prompt_text())];
145 } 147 }
146 [alert_ setDelegate:helper_]; 148 [alert_ setDelegate:helper_];
147 NSString* informative_text = 149 NSString* informative_text =
148 base::SysUTF16ToNSString(dialog_->message_text()); 150 base::SysUTF16ToNSString(dialog_->message_text());
151
152 NSArray * informative_text_array =
jeremy 2014/01/21 21:24:39 Add a comment with a link to the bug - something l
153 [informative_text componentsSeparatedByCharactersInSet:
154 [NSCharacterSet newlineCharacterSet]];
155 if ([informative_text_array count] > kMessageTextMaxRows) {
156 informative_text = [[[[informative_text_array subarrayWithRange:
157 NSMakeRange(0, kMessageTextMaxRows)] valueForKey:@"description"]
158 componentsJoinedByString:@"\n"] stringByAppendingString:@"\n..."];
jeremy 2014/01/21 21:24:39 Can you split this up into 3 or 4 statements so th
159 }
160
149 [alert_ setInformativeText:informative_text]; 161 [alert_ setInformativeText:informative_text];
150 NSString* message_text = 162 NSString* message_text =
151 base::SysUTF16ToNSString(dialog_->title()); 163 base::SysUTF16ToNSString(dialog_->title());
152 [alert_ setMessageText:message_text]; 164 [alert_ setMessageText:message_text];
153 [alert_ addButtonWithTitle:default_button]; 165 [alert_ addButtonWithTitle:default_button];
154 if (!one_button) { 166 if (!one_button) {
155 NSButton* other = [alert_ addButtonWithTitle:other_button]; 167 NSButton* other = [alert_ addButtonWithTitle:other_button];
156 [other setKeyEquivalent:@"\e"]; 168 [other setKeyEquivalent:@"\e"];
157 } 169 }
158 if (dialog_->display_suppress_checkbox()) { 170 if (dialog_->display_suppress_checkbox()) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 310
299 //////////////////////////////////////////////////////////////////////////////// 311 ////////////////////////////////////////////////////////////////////////////////
300 // NativeAppModalDialog, public: 312 // NativeAppModalDialog, public:
301 313
302 // static 314 // static
303 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt( 315 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt(
304 JavaScriptAppModalDialog* dialog, 316 JavaScriptAppModalDialog* dialog,
305 gfx::NativeWindow parent_window) { 317 gfx::NativeWindow parent_window) {
306 return new JavaScriptAppModalDialogCocoa(dialog); 318 return new JavaScriptAppModalDialogCocoa(dialog);
307 } 319 }
OLDNEW
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698