Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/url_formatter/elide_url.h" | 5 #include "components/url_formatter/elide_url.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 return base::ASCIIToUTF16(url::kFileSystemScheme) + colon + | 133 return base::ASCIIToUTF16(url::kFileSystemScheme) + colon + |
| 134 FormatUrlForSecurityDisplayInternal(*inner_url, languages, | 134 FormatUrlForSecurityDisplayInternal(*inner_url, languages, |
| 135 false /*omit_scheme*/); | 135 false /*omit_scheme*/); |
| 136 } | 136 } |
| 137 | 137 |
| 138 const GURL origin = url.GetOrigin(); | 138 const GURL origin = url.GetOrigin(); |
| 139 const std::string& scheme = origin.scheme(); | 139 const std::string& scheme = origin.scheme(); |
| 140 const std::string& host = origin.host(); | 140 const std::string& host = origin.host(); |
| 141 | 141 |
| 142 base::string16 result; | 142 base::string16 result; |
| 143 if (!omit_scheme || !url.SchemeIsHTTPOrHTTPS()) | 143 if (!omit_scheme || !url.SchemeIs(url::kHttpsScheme)) |
|
palmer
2016/03/30 20:23:34
Maybe url.SchemeIsCryptographic()?
| |
| 144 result = base::UTF8ToUTF16(scheme) + scheme_separator; | 144 result = base::UTF8ToUTF16(scheme) + scheme_separator; |
| 145 result += base::UTF8ToUTF16(host); | 145 result += base::UTF8ToUTF16(host); |
| 146 | 146 |
| 147 const int port = origin.IntPort(); | 147 const int port = origin.IntPort(); |
| 148 const int default_port = url::DefaultPortForScheme( | 148 const int default_port = url::DefaultPortForScheme( |
| 149 scheme.c_str(), static_cast<int>(scheme.length())); | 149 scheme.c_str(), static_cast<int>(scheme.length())); |
| 150 if (port != url::PORT_UNSPECIFIED && port != default_port) | 150 if (port != url::PORT_UNSPECIFIED && port != default_port) |
| 151 result += colon + base::UTF8ToUTF16(origin.port()); | 151 result += colon + base::UTF8ToUTF16(origin.port()); |
| 152 | 152 |
| 153 return result; | 153 return result; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 363 return FormatUrlForSecurityDisplayInternal(url, languages, false); | 363 return FormatUrlForSecurityDisplayInternal(url, languages, false); |
| 364 } | 364 } |
| 365 | 365 |
| 366 base::string16 FormatUrlForSecurityDisplayOmitScheme( | 366 base::string16 FormatUrlForSecurityDisplayOmitScheme( |
| 367 const GURL& url, | 367 const GURL& url, |
| 368 const std::string& languages) { | 368 const std::string& languages) { |
| 369 return FormatUrlForSecurityDisplayInternal(url, languages, true); | 369 return FormatUrlForSecurityDisplayInternal(url, languages, true); |
| 370 } | 370 } |
| 371 | 371 |
| 372 } // namespace url_formatter | 372 } // namespace url_formatter |
| OLD | NEW |