Chromium Code Reviews| Index: ios/chrome/browser/ui/dialogs/dialog_presenter.mm |
| diff --git a/ios/chrome/browser/ui/dialogs/dialog_presenter.mm b/ios/chrome/browser/ui/dialogs/dialog_presenter.mm |
| index 123efbab920d3da285aa64f346a7ec44cd282959..5c32df8a0c74809ee9436364d95ace8c336a039f 100644 |
| --- a/ios/chrome/browser/ui/dialogs/dialog_presenter.mm |
| +++ b/ios/chrome/browser/ui/dialogs/dialog_presenter.mm |
| @@ -134,8 +134,9 @@ NSString* const kJavaScriptDialogTextFieldAccessibiltyIdentifier = |
| requestURL:(const GURL&)requestURL |
| webState:(web::WebState*)webState |
| completionHandler:(void (^)(void))completionHandler { |
| - NSString* title = |
| - [DialogPresenter localizedTitleForJavaScriptAlertFromPage:requestURL]; |
| + NSString* title = [DialogPresenter |
| + localizedTitleForJavaScriptAlertFromPage:requestURL |
| + mainFrameURL:webState->GetLastCommittedURL()]; |
| AlertCoordinator* alertCoordinator = |
| [[AlertCoordinator alloc] initWithBaseViewController:self.viewController |
| title:title |
| @@ -170,8 +171,9 @@ NSString* const kJavaScriptDialogTextFieldAccessibiltyIdentifier = |
| webState:(web::WebState*)webState |
| completionHandler: |
| (void (^)(BOOL isConfirmed))completionHandler { |
| - NSString* title = |
| - [DialogPresenter localizedTitleForJavaScriptAlertFromPage:requestURL]; |
| + NSString* title = [DialogPresenter |
| + localizedTitleForJavaScriptAlertFromPage:requestURL |
| + mainFrameURL:webState->GetLastCommittedURL()]; |
|
PL
2017/06/28 23:18:34
Is GetLastCommittedURL() the right URL to use here
|
| AlertCoordinator* alertCoordinator = |
| [[AlertCoordinator alloc] initWithBaseViewController:self.viewController |
| title:title |
| @@ -207,8 +209,9 @@ NSString* const kJavaScriptDialogTextFieldAccessibiltyIdentifier = |
| webState:(web::WebState*)webState |
| completionHandler: |
| (void (^)(NSString* input))completionHandler { |
| - NSString* title = |
| - [DialogPresenter localizedTitleForJavaScriptAlertFromPage:requestURL]; |
| + NSString* title = [DialogPresenter |
| + localizedTitleForJavaScriptAlertFromPage:requestURL |
| + mainFrameURL:webState->GetLastCommittedURL()]; |
| InputAlertCoordinator* alertCoordinator = [[InputAlertCoordinator alloc] |
| initWithBaseViewController:self.viewController |
| title:title |
| @@ -350,9 +353,20 @@ NSString* const kJavaScriptDialogTextFieldAccessibiltyIdentifier = |
| } |
| + (NSString*)localizedTitleForJavaScriptAlertFromPage:(const GURL&)pageURL { |
| + return [self localizedTitleForJavaScriptAlertFromPage:pageURL |
| + mainFrameURL:pageURL]; |
| +} |
| + |
| ++ (NSString*)localizedTitleForJavaScriptAlertFromPage:(const GURL&)pageURL |
| + mainFrameURL: |
| + (const GURL&)mainFrameURL { |
| NSString* localizedTitle = nil; |
| NSString* hostname = base::SysUTF8ToNSString(pageURL.host()); |
| - if (!hostname.length) { |
| + |
| + bool is_same_origin_as_main_frame = |
|
Eugene But (OOO till 7-30)
2017/06/29 01:00:01
s/is_same_origin_as_main_frame/sameOriginAsMainFra
PL
2017/06/29 20:02:21
Thanks! I'm not sure how long it will take me to g
|
| + pageURL.GetOrigin() == mainFrameURL.GetOrigin(); |
| + |
| + if (!is_same_origin_as_main_frame) { |
| localizedTitle = l10n_util::GetNSString( |
| IDS_JAVASCRIPT_MESSAGEBOX_TITLE_NONSTANDARD_URL_IFRAME); |
| } else { |