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

Side by Side Diff: ios/chrome/browser/ui/dialogs/dialog_presenter.mm

Issue 2944243002: Improve dialog titles generated by embedded pages. (Closed)
Patch Set: Created 3 years, 6 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 | « no previous file | 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #import "ios/chrome/browser/ui/dialogs/dialog_presenter.h" 5 #import "ios/chrome/browser/ui/dialogs/dialog_presenter.h"
6 6
7 #include <deque> 7 #include <deque>
8 #include <map> 8 #include <map>
9 9
10 #import "base/ios/block_types.h" 10 #import "base/ios/block_types.h"
(...skipping 13 matching lines...) Expand all
24 #include "url/gurl.h" 24 #include "url/gurl.h"
25 25
26 #if !defined(__has_feature) || !__has_feature(objc_arc) 26 #if !defined(__has_feature) || !__has_feature(objc_arc)
27 #error "This file requires ARC support." 27 #error "This file requires ARC support."
28 #endif 28 #endif
29 29
30 // Externed accessibility identifier. 30 // Externed accessibility identifier.
31 NSString* const kJavaScriptDialogTextFieldAccessibiltyIdentifier = 31 NSString* const kJavaScriptDialogTextFieldAccessibiltyIdentifier =
32 @"JavaScriptDialogTextFieldAccessibiltyIdentifier"; 32 @"JavaScriptDialogTextFieldAccessibiltyIdentifier";
33 33
34 namespace {
35 // The hostname to use for JavaScript alerts when there is no valid hostname in
36 // the URL passed to |+localizedTitleForJavaScriptAlertFromPage:type:|.
37 const char kAboutNullHostname[] = "about:null";
38 } // namespace
39
40 @interface DialogPresenter () { 34 @interface DialogPresenter () {
41 // Queue of WebStates which correspond to the keys in 35 // Queue of WebStates which correspond to the keys in
42 // |_dialogCoordinatorsForWebStates|. 36 // |_dialogCoordinatorsForWebStates|.
43 std::deque<web::WebState*> _queuedWebStates; 37 std::deque<web::WebState*> _queuedWebStates;
44 // A map associating queued webStates with their coordinators. 38 // A map associating queued webStates with their coordinators.
45 std::map<web::WebState*, base::scoped_nsobject<AlertCoordinator>> 39 std::map<web::WebState*, base::scoped_nsobject<AlertCoordinator>>
46 _dialogCoordinatorsForWebStates; 40 _dialogCoordinatorsForWebStates;
47 } 41 }
48 42
49 // The delegate passed on initialization. 43 // The delegate passed on initialization.
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 // displayed. 334 // displayed.
341 if (self.blockingConfirmationCoordinator) 335 if (self.blockingConfirmationCoordinator)
342 return; 336 return;
343 // The active TabModel can't be changed while a JavaScript dialog is shown. 337 // The active TabModel can't be changed while a JavaScript dialog is shown.
344 DCHECK(!self.showingDialog); 338 DCHECK(!self.showingDialog);
345 if (_active && !_queuedWebStates.empty() && !self.delegate.presenting) 339 if (_active && !_queuedWebStates.empty() && !self.delegate.presenting)
346 [self showNextDialog]; 340 [self showNextDialog];
347 } 341 }
348 342
349 + (NSString*)localizedTitleForJavaScriptAlertFromPage:(const GURL&)pageURL { 343 + (NSString*)localizedTitleForJavaScriptAlertFromPage:(const GURL&)pageURL {
344 NSString* localizedTitle = nil;
350 NSString* hostname = base::SysUTF8ToNSString(pageURL.host()); 345 NSString* hostname = base::SysUTF8ToNSString(pageURL.host());
351 if (!hostname.length) 346 if (!hostname.length) {
Eugene But (OOO till 7-30) 2017/06/22 20:19:12 Other platforms use IDS_JAVASCRIPT_MESSAGEBOX_TITL
352 hostname = base::SysUTF8ToNSString(kAboutNullHostname); 347 localizedTitle = l10n_util::GetNSString(
353 return l10n_util::GetNSStringF(IDS_JAVASCRIPT_MESSAGEBOX_TITLE, 348 IDS_JAVASCRIPT_MESSAGEBOX_TITLE_NONSTANDARD_URL_IFRAME);
354 base::SysNSStringToUTF16(hostname)); 349 } else {
350 localizedTitle = l10n_util::GetNSStringF(
351 IDS_JAVASCRIPT_MESSAGEBOX_TITLE, base::SysNSStringToUTF16(hostname));
352 }
353 return localizedTitle;
355 } 354 }
356 355
357 #pragma mark - Private methods. 356 #pragma mark - Private methods.
358 357
359 - (void)addDialogCoordinator:(AlertCoordinator*)coordinator 358 - (void)addDialogCoordinator:(AlertCoordinator*)coordinator
360 forWebState:(web::WebState*)webState { 359 forWebState:(web::WebState*)webState {
361 DCHECK(coordinator); 360 DCHECK(coordinator);
362 DCHECK(webState); 361 DCHECK(webState);
363 DCHECK_NE(webState, self.presentedDialogWebState); 362 DCHECK_NE(webState, self.presentedDialogWebState);
364 DCHECK(!_dialogCoordinatorsForWebStates[webState]); 363 DCHECK(!_dialogCoordinatorsForWebStates[webState]);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 style:UIAlertActionStyleDestructive]; 498 style:UIAlertActionStyleDestructive];
500 [confirmationCoordinator addItemWithTitle:l10n_util::GetNSString(IDS_CANCEL) 499 [confirmationCoordinator addItemWithTitle:l10n_util::GetNSString(IDS_CANCEL)
501 action:cancelHandler 500 action:cancelHandler
502 style:UIAlertActionStyleCancel]; 501 style:UIAlertActionStyleCancel];
503 [weakSelf setBlockingConfirmationCoordinator:confirmationCoordinator]; 502 [weakSelf setBlockingConfirmationCoordinator:confirmationCoordinator];
504 [[weakSelf blockingConfirmationCoordinator] start]; 503 [[weakSelf blockingConfirmationCoordinator] start];
505 } copy]; 504 } copy];
506 } 505 }
507 506
508 @end 507 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698