Chromium Code Reviews| 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/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 10 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 27 #include "content/public/browser/web_ui.h" | 27 #include "content/public/browser/web_ui.h" |
| 28 #include "content/public/common/content_constants.h" | 28 #include "content/public/common/content_constants.h" |
| 29 #include "content/public/common/ssl_status.h" | 29 #include "content/public/common/ssl_status.h" |
| 30 #include "grit/components_scaled_resources.h" | 30 #include "grit/components_scaled_resources.h" |
| 31 #include "grit/theme_resources.h" | 31 #include "grit/theme_resources.h" |
| 32 #include "net/cert/cert_status_flags.h" | 32 #include "net/cert/cert_status_flags.h" |
| 33 #include "net/cert/x509_certificate.h" | 33 #include "net/cert/x509_certificate.h" |
| 34 #include "net/ssl/ssl_connection_status_flags.h" | 34 #include "net/ssl/ssl_connection_status_flags.h" |
| 35 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
| 36 #include "ui/gfx/vector_icons_public.h" | |
| 36 | 37 |
| 37 using content::NavigationController; | 38 using content::NavigationController; |
| 38 using content::NavigationEntry; | 39 using content::NavigationEntry; |
| 39 using content::WebContents; | 40 using content::WebContents; |
| 40 | 41 |
| 41 ToolbarModelImpl::ToolbarModelImpl(ToolbarModelDelegate* delegate) | 42 ToolbarModelImpl::ToolbarModelImpl(ToolbarModelDelegate* delegate) |
| 42 : delegate_(delegate) { | 43 : delegate_(delegate) { |
| 43 } | 44 } |
| 44 | 45 |
| 45 ToolbarModelImpl::~ToolbarModelImpl() { | 46 ToolbarModelImpl::~ToolbarModelImpl() { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 const SecurityStateModel* model = | 120 const SecurityStateModel* model = |
| 120 SecurityStateModel::FromWebContents(web_contents); | 121 SecurityStateModel::FromWebContents(web_contents); |
| 121 | 122 |
| 122 // When editing, assume no security style. | 123 // When editing, assume no security style. |
| 123 return (input_in_progress() && !ignore_editing) | 124 return (input_in_progress() && !ignore_editing) |
| 124 ? SecurityStateModel::NONE | 125 ? SecurityStateModel::NONE |
| 125 : model->GetSecurityInfo().security_level; | 126 : model->GetSecurityInfo().security_level; |
| 126 } | 127 } |
| 127 | 128 |
| 128 int ToolbarModelImpl::GetIcon() const { | 129 int ToolbarModelImpl::GetIcon() const { |
| 129 if (WouldPerformSearchTermReplacement(false)) | |
| 130 return IDR_OMNIBOX_SEARCH_SECURED; | |
| 131 | |
| 132 return GetIconForSecurityLevel(GetSecurityLevel(false)); | 130 return GetIconForSecurityLevel(GetSecurityLevel(false)); |
|
Peter Kasting
2015/10/21 19:45:47
I think GetIconForSecurityLevel() is now only call
Evan Stade
2015/10/21 23:20:01
Done.
| |
| 133 } | 131 } |
| 134 | 132 |
| 135 int ToolbarModelImpl::GetIconForSecurityLevel( | 133 int ToolbarModelImpl::GetIconForSecurityLevel( |
| 136 SecurityStateModel::SecurityLevel level) const { | 134 SecurityStateModel::SecurityLevel level) const { |
| 137 switch (level) { | 135 switch (level) { |
| 138 case SecurityStateModel::NONE: | 136 case SecurityStateModel::NONE: |
| 139 return IDR_LOCATION_BAR_HTTP; | 137 return IDR_LOCATION_BAR_HTTP; |
| 140 case SecurityStateModel::EV_SECURE: | 138 case SecurityStateModel::EV_SECURE: |
| 141 case SecurityStateModel::SECURE: | 139 case SecurityStateModel::SECURE: |
| 142 return IDR_OMNIBOX_HTTPS_VALID; | 140 return IDR_OMNIBOX_HTTPS_VALID; |
| 143 case SecurityStateModel::SECURITY_WARNING: | 141 case SecurityStateModel::SECURITY_WARNING: |
| 144 // Surface Dubious as Neutral. | 142 // Surface Dubious as Neutral. |
| 145 return IDR_LOCATION_BAR_HTTP; | 143 return IDR_LOCATION_BAR_HTTP; |
| 146 case SecurityStateModel::SECURITY_POLICY_WARNING: | 144 case SecurityStateModel::SECURITY_POLICY_WARNING: |
| 147 return IDR_OMNIBOX_HTTPS_POLICY_WARNING; | 145 return IDR_OMNIBOX_HTTPS_POLICY_WARNING; |
| 148 case SecurityStateModel::SECURITY_ERROR: | 146 case SecurityStateModel::SECURITY_ERROR: |
| 149 return IDR_OMNIBOX_HTTPS_INVALID; | 147 return IDR_OMNIBOX_HTTPS_INVALID; |
| 150 } | 148 } |
| 151 | 149 |
| 152 NOTREACHED(); | 150 NOTREACHED(); |
| 153 return IDR_LOCATION_BAR_HTTP; | 151 return IDR_LOCATION_BAR_HTTP; |
| 154 } | 152 } |
| 155 | 153 |
| 154 gfx::VectorIconId ToolbarModelImpl::GetVectorIcon() const { | |
| 155 return GetVectorIconForSecurityLevel(GetSecurityLevel(false)); | |
| 156 } | |
| 157 | |
| 158 gfx::VectorIconId ToolbarModelImpl::GetVectorIconForSecurityLevel( | |
| 159 SecurityStateModel::SecurityLevel level) const { | |
| 160 #if !defined(OS_ANDROID) && !defined(OS_MACOSX) && !defined(OS_IOS) | |
| 161 switch (level) { | |
| 162 case SecurityStateModel::NONE: | |
| 163 return gfx::VectorIconId::LOCATION_BAR_HTTP; | |
| 164 case SecurityStateModel::EV_SECURE: | |
| 165 case SecurityStateModel::SECURE: | |
| 166 return gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID; | |
| 167 case SecurityStateModel::SECURITY_WARNING: | |
| 168 // Surface Dubious as Neutral. | |
| 169 return gfx::VectorIconId::LOCATION_BAR_HTTP; | |
| 170 case SecurityStateModel::SECURITY_POLICY_WARNING: | |
| 171 return gfx::VectorIconId::BUSINESS; | |
|
Peter Kasting
2015/10/21 19:45:47
It's not at all obvious what this is from the name
Evan Stade
2015/10/21 23:20:01
Yes, "business" is the name of this icon, which is
Peter Kasting
2015/10/22 00:05:24
FWIW, I'd like to rename all the icons to match th
| |
| 172 case SecurityStateModel::SECURITY_ERROR: | |
| 173 return gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID; | |
| 174 } | |
| 175 #endif | |
| 176 | |
| 177 NOTREACHED(); | |
| 178 return gfx::VectorIconId::LOCATION_BAR_HTTP; | |
| 179 } | |
| 180 | |
| 156 base::string16 ToolbarModelImpl::GetEVCertName() const { | 181 base::string16 ToolbarModelImpl::GetEVCertName() const { |
| 157 if (GetSecurityLevel(false) != SecurityStateModel::EV_SECURE) | 182 if (GetSecurityLevel(false) != SecurityStateModel::EV_SECURE) |
| 158 return base::string16(); | 183 return base::string16(); |
| 159 | 184 |
| 160 // Note: Navigation controller and active entry are guaranteed non-NULL or | 185 // Note: Navigation controller and active entry are guaranteed non-NULL or |
| 161 // the security level would be NONE. | 186 // the security level would be NONE. |
| 162 scoped_refptr<net::X509Certificate> cert; | 187 scoped_refptr<net::X509Certificate> cert; |
| 163 content::CertStore::GetInstance()->RetrieveCert( | 188 content::CertStore::GetInstance()->RetrieveCert( |
| 164 GetNavigationController()->GetVisibleEntry()->GetSSL().cert_id, &cert); | 189 GetNavigationController()->GetVisibleEntry()->GetSSL().cert_id, &cert); |
| 165 | 190 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 | 272 |
| 248 // Otherwise, extract search terms for HTTPS pages that do not have a security | 273 // Otherwise, extract search terms for HTTPS pages that do not have a security |
| 249 // error. | 274 // error. |
| 250 SecurityStateModel::SecurityLevel security_level = | 275 SecurityStateModel::SecurityLevel security_level = |
| 251 GetSecurityLevel(ignore_editing); | 276 GetSecurityLevel(ignore_editing); |
| 252 return ((security_level == SecurityStateModel::NONE) || | 277 return ((security_level == SecurityStateModel::NONE) || |
| 253 (security_level == SecurityStateModel::SECURITY_ERROR)) | 278 (security_level == SecurityStateModel::SECURITY_ERROR)) |
| 254 ? base::string16() | 279 ? base::string16() |
| 255 : search_terms; | 280 : search_terms; |
| 256 } | 281 } |
| OLD | NEW |