Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/nsurl_protection_space_util.h" | 5 #import "ios/chrome/browser/ui/dialogs/nsurl_protection_space_util.h" |
| 6 | 6 |
| 7 #include "base/numerics/safe_conversions.h" | 7 #include "base/numerics/safe_conversions.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "components/strings/grit/components_strings.h" | 9 #include "components/strings/grit/components_strings.h" |
| 10 #include "components/url_formatter/elide_url.h" | 10 #include "components/url_formatter/elide_url.h" |
| 11 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
| 12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 13 #include "url/scheme_host_port.h" | 13 #include "url/scheme_host_port.h" |
| 14 | 14 |
| 15 #if !defined(__has_feature) || !__has_feature(objc_arc) | 15 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 16 #error "This file requires ARC support." | 16 #error "This file requires ARC support." |
| 17 #endif | 17 #endif |
| 18 | 18 |
| 19 namespace ios_internal { | 19 namespace ios_internal { |
| 20 namespace nsurlprotectionspace_util { | 20 namespace nsurlprotectionspace_util { |
| 21 | 21 |
| 22 NSString* MessageForHTTPAuth(NSURLProtectionSpace* protectionSpace) { | 22 NSString* MessageForHTTPAuth(NSURLProtectionSpace* protectionSpace) { |
| 23 DCHECK(CanShow(protectionSpace)); | 23 DCHECK(CanShow(protectionSpace)); |
| 24 | 24 |
| 25 if (protectionSpace.receivesCredentialSecurely) | 25 if (protectionSpace.receivesCredentialSecurely) |
| 26 return RequesterIdentity(protectionSpace); | 26 return RequesterIdentity(protectionSpace); |
| 27 | 27 |
| 28 NSString* securityWarning = | 28 NSString* securityWarning = |
| 29 l10n_util::GetNSString(IDS_PAGE_INFO_NON_SECURE_TRANSPORT); | 29 l10n_util::GetNSString(IDS_PAGEINFO_NOT_SECURE_SUMMARY); |
|
estark
2017/04/28 04:49:31
It's a little weird that these http auth dialogs u
meacer
2017/04/28 15:28:40
ISTR they were added when we decided we couldn't r
| |
| 30 return | 30 return |
| 31 [NSString stringWithFormat:@"%@ %@", RequesterIdentity(protectionSpace), | 31 [NSString stringWithFormat:@"%@ %@", RequesterIdentity(protectionSpace), |
| 32 securityWarning]; | 32 securityWarning]; |
| 33 } | 33 } |
| 34 | 34 |
| 35 BOOL CanShow(NSURLProtectionSpace* protectionSpace) { | 35 BOOL CanShow(NSURLProtectionSpace* protectionSpace) { |
| 36 if (protectionSpace.host.length == 0) | 36 if (protectionSpace.host.length == 0) |
| 37 return NO; | 37 return NO; |
| 38 | 38 |
| 39 if (!base::IsValueInRangeForNumericType<uint16_t>(protectionSpace.port)) | 39 if (!base::IsValueInRangeForNumericType<uint16_t>(protectionSpace.port)) |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 63 GURL RequesterOrigin(NSURLProtectionSpace* protectionSpace) { | 63 GURL RequesterOrigin(NSURLProtectionSpace* protectionSpace) { |
| 64 std::string scheme = base::SysNSStringToUTF8(protectionSpace.protocol); | 64 std::string scheme = base::SysNSStringToUTF8(protectionSpace.protocol); |
| 65 std::string host = base::SysNSStringToUTF8(protectionSpace.host); | 65 std::string host = base::SysNSStringToUTF8(protectionSpace.host); |
| 66 uint16_t port = base::checked_cast<uint16_t>(protectionSpace.port); | 66 uint16_t port = base::checked_cast<uint16_t>(protectionSpace.port); |
| 67 | 67 |
| 68 return GURL(url::SchemeHostPort(scheme, host, port).Serialize()); | 68 return GURL(url::SchemeHostPort(scheme, host, port).Serialize()); |
| 69 } | 69 } |
| 70 | 70 |
| 71 } // namespace nsurlprotectionspace_util | 71 } // namespace nsurlprotectionspace_util |
| 72 } // namespace ios_internal | 72 } // namespace ios_internal |
| OLD | NEW |