| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/toolbar/toolbar_model_impl.h" | 5 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 10 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 content::CertStore::GetInstance()->RetrieveCert(ssl.cert_id, NULL)) | 88 content::CertStore::GetInstance()->RetrieveCert(ssl.cert_id, NULL)) |
| 89 return EV_SECURE; | 89 return EV_SECURE; |
| 90 return SECURE; | 90 return SECURE; |
| 91 } | 91 } |
| 92 default: | 92 default: |
| 93 NOTREACHED(); | 93 NOTREACHED(); |
| 94 return NONE; | 94 return NONE; |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 | 97 |
| 98 // static | |
| 99 base::string16 ToolbarModelImpl::GetEVCertName( | |
| 100 const net::X509Certificate& cert) { | |
| 101 // EV are required to have an organization name and country. | |
| 102 DCHECK(!cert.subject().organization_names.empty()); | |
| 103 DCHECK(!cert.subject().country_name.empty()); | |
| 104 | |
| 105 return l10n_util::GetStringFUTF16( | |
| 106 IDS_SECURE_CONNECTION_EV, | |
| 107 base::UTF8ToUTF16(cert.subject().organization_names[0]), | |
| 108 base::UTF8ToUTF16(cert.subject().country_name)); | |
| 109 } | |
| 110 | |
| 111 // ToolbarModelImpl Implementation. | 98 // ToolbarModelImpl Implementation. |
| 112 base::string16 ToolbarModelImpl::GetText() const { | 99 base::string16 ToolbarModelImpl::GetText() const { |
| 113 base::string16 search_terms(GetSearchTerms(false)); | 100 base::string16 search_terms(GetSearchTerms(false)); |
| 114 if (!search_terms.empty()) | 101 if (!search_terms.empty()) |
| 115 return search_terms; | 102 return search_terms; |
| 116 | 103 |
| 117 if (WouldOmitURLDueToOriginChip()) | 104 if (WouldOmitURLDueToOriginChip()) |
| 118 return base::string16(); | 105 return base::string16(); |
| 119 | 106 |
| 120 return GetFormattedURL(); | 107 return GetFormattedURL(); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 IDR_OMNIBOX_HTTPS_VALID, | 187 IDR_OMNIBOX_HTTPS_VALID, |
| 201 IDR_OMNIBOX_HTTPS_WARNING, | 188 IDR_OMNIBOX_HTTPS_WARNING, |
| 202 IDR_OMNIBOX_HTTPS_POLICY_WARNING, | 189 IDR_OMNIBOX_HTTPS_POLICY_WARNING, |
| 203 IDR_OMNIBOX_HTTPS_INVALID, | 190 IDR_OMNIBOX_HTTPS_INVALID, |
| 204 }; | 191 }; |
| 205 DCHECK(arraysize(icon_ids) == NUM_SECURITY_LEVELS); | 192 DCHECK(arraysize(icon_ids) == NUM_SECURITY_LEVELS); |
| 206 return icon_ids[level]; | 193 return icon_ids[level]; |
| 207 } | 194 } |
| 208 | 195 |
| 209 base::string16 ToolbarModelImpl::GetEVCertName() const { | 196 base::string16 ToolbarModelImpl::GetEVCertName() const { |
| 210 DCHECK_EQ(EV_SECURE, GetSecurityLevel(false)); | 197 if (GetSecurityLevel(false) != EV_SECURE) |
| 211 scoped_refptr<net::X509Certificate> cert; | 198 return base::string16(); |
| 199 |
| 212 // Note: Navigation controller and active entry are guaranteed non-NULL or | 200 // Note: Navigation controller and active entry are guaranteed non-NULL or |
| 213 // the security level would be NONE. | 201 // the security level would be NONE. |
| 202 scoped_refptr<net::X509Certificate> cert; |
| 214 content::CertStore::GetInstance()->RetrieveCert( | 203 content::CertStore::GetInstance()->RetrieveCert( |
| 215 GetNavigationController()->GetVisibleEntry()->GetSSL().cert_id, &cert); | 204 GetNavigationController()->GetVisibleEntry()->GetSSL().cert_id, &cert); |
| 216 return GetEVCertName(*cert.get()); | 205 |
| 206 // EV are required to have an organization name and country. |
| 207 DCHECK(!cert->subject().organization_names.empty()); |
| 208 DCHECK(!cert->subject().country_name.empty()); |
| 209 return l10n_util::GetStringFUTF16( |
| 210 IDS_SECURE_CONNECTION_EV, |
| 211 base::UTF8ToUTF16(cert->subject().organization_names[0]), |
| 212 base::UTF8ToUTF16(cert->subject().country_name)); |
| 217 } | 213 } |
| 218 | 214 |
| 219 bool ToolbarModelImpl::ShouldDisplayURL() const { | 215 bool ToolbarModelImpl::ShouldDisplayURL() const { |
| 220 // Note: The order here is important. | 216 // Note: The order here is important. |
| 221 // - The WebUI test must come before the extension scheme test because there | 217 // - The WebUI test must come before the extension scheme test because there |
| 222 // can be WebUIs that have extension schemes (e.g. the bookmark manager). In | 218 // can be WebUIs that have extension schemes (e.g. the bookmark manager). In |
| 223 // that case, we should prefer what the WebUI instance says. | 219 // that case, we should prefer what the WebUI instance says. |
| 224 // - The view-source test must come before the NTP test because of the case | 220 // - The view-source test must come before the NTP test because of the case |
| 225 // of view-source:chrome://newtab, which should display its URL despite what | 221 // of view-source:chrome://newtab, which should display its URL despite what |
| 226 // chrome://newtab says. | 222 // chrome://newtab says. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 if (entry && | 326 if (entry && |
| 331 google_util::StartsWithCommandLineGoogleBaseURL(entry->GetVirtualURL())) | 327 google_util::StartsWithCommandLineGoogleBaseURL(entry->GetVirtualURL())) |
| 332 return search_terms; | 328 return search_terms; |
| 333 | 329 |
| 334 // Otherwise, extract search terms for HTTPS pages that do not have a security | 330 // Otherwise, extract search terms for HTTPS pages that do not have a security |
| 335 // error. | 331 // error. |
| 336 ToolbarModel::SecurityLevel security_level = GetSecurityLevel(ignore_editing); | 332 ToolbarModel::SecurityLevel security_level = GetSecurityLevel(ignore_editing); |
| 337 return ((security_level == NONE) || (security_level == SECURITY_ERROR)) ? | 333 return ((security_level == NONE) || (security_level == SECURITY_ERROR)) ? |
| 338 base::string16() : search_terms; | 334 base::string16() : search_terms; |
| 339 } | 335 } |
| OLD | NEW |