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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 if (WouldPerformSearchTermReplacement(false)) |
130 return IDR_OMNIBOX_SEARCH_SECURED; | 131 return IDR_OMNIBOX_SEARCH_SECURED; |
Evan Stade
2015/10/20 21:21:28
is it actually possible to hit this? How would one
Peter Kasting
2015/10/20 23:15:28
Search term replacement is dead and there's a bug
Evan Stade
2015/10/21 17:00:13
guess i can delete this resource then
| |
131 | 132 |
132 return GetIconForSecurityLevel(GetSecurityLevel(false)); | 133 return GetIconForSecurityLevel(GetSecurityLevel(false)); |
133 } | 134 } |
134 | 135 |
135 int ToolbarModelImpl::GetIconForSecurityLevel( | 136 int ToolbarModelImpl::GetIconForSecurityLevel( |
136 SecurityStateModel::SecurityLevel level) const { | 137 SecurityStateModel::SecurityLevel level) const { |
137 switch (level) { | 138 switch (level) { |
138 case SecurityStateModel::NONE: | 139 case SecurityStateModel::NONE: |
139 return IDR_LOCATION_BAR_HTTP; | 140 return IDR_LOCATION_BAR_HTTP; |
140 case SecurityStateModel::EV_SECURE: | 141 case SecurityStateModel::EV_SECURE: |
141 case SecurityStateModel::SECURE: | 142 case SecurityStateModel::SECURE: |
142 return IDR_OMNIBOX_HTTPS_VALID; | 143 return IDR_OMNIBOX_HTTPS_VALID; |
143 case SecurityStateModel::SECURITY_WARNING: | 144 case SecurityStateModel::SECURITY_WARNING: |
144 // Surface Dubious as Neutral. | 145 // Surface Dubious as Neutral. |
145 return IDR_LOCATION_BAR_HTTP; | 146 return IDR_LOCATION_BAR_HTTP; |
146 case SecurityStateModel::SECURITY_POLICY_WARNING: | 147 case SecurityStateModel::SECURITY_POLICY_WARNING: |
147 return IDR_OMNIBOX_HTTPS_POLICY_WARNING; | 148 return IDR_OMNIBOX_HTTPS_POLICY_WARNING; |
148 case SecurityStateModel::SECURITY_ERROR: | 149 case SecurityStateModel::SECURITY_ERROR: |
149 return IDR_OMNIBOX_HTTPS_INVALID; | 150 return IDR_OMNIBOX_HTTPS_INVALID; |
150 } | 151 } |
151 | 152 |
152 NOTREACHED(); | 153 NOTREACHED(); |
153 return IDR_LOCATION_BAR_HTTP; | 154 return IDR_LOCATION_BAR_HTTP; |
154 } | 155 } |
155 | 156 |
157 gfx::VectorIconId ToolbarModelImpl::GetVectorIcon() const { | |
158 DCHECK(!WouldPerformSearchTermReplacement(false)); | |
159 return GetVectorIconForSecurityLevel(GetSecurityLevel(false)); | |
160 } | |
161 | |
162 gfx::VectorIconId ToolbarModelImpl::GetVectorIconForSecurityLevel( | |
163 SecurityStateModel::SecurityLevel level) const { | |
164 #if !defined(OS_ANDROID) && !defined(OS_MACOSX) && !defined(OS_IOS) | |
165 switch (level) { | |
166 case SecurityStateModel::NONE: | |
167 return gfx::VectorIconId::LOCATION_BAR_HTTP; | |
168 case SecurityStateModel::EV_SECURE: | |
169 case SecurityStateModel::SECURE: | |
170 return gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID; | |
171 case SecurityStateModel::SECURITY_WARNING: | |
172 // Surface Dubious as Neutral. | |
173 return gfx::VectorIconId::LOCATION_BAR_HTTP; | |
174 case SecurityStateModel::SECURITY_POLICY_WARNING: | |
175 return gfx::VectorIconId::BUSINESS; | |
176 case SecurityStateModel::SECURITY_ERROR: | |
177 return gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID; | |
178 } | |
179 #endif | |
180 | |
181 NOTREACHED(); | |
182 return gfx::VectorIconId::LOCATION_BAR_HTTP; | |
183 } | |
184 | |
156 base::string16 ToolbarModelImpl::GetEVCertName() const { | 185 base::string16 ToolbarModelImpl::GetEVCertName() const { |
157 if (GetSecurityLevel(false) != SecurityStateModel::EV_SECURE) | 186 if (GetSecurityLevel(false) != SecurityStateModel::EV_SECURE) |
158 return base::string16(); | 187 return base::string16(); |
159 | 188 |
160 // Note: Navigation controller and active entry are guaranteed non-NULL or | 189 // Note: Navigation controller and active entry are guaranteed non-NULL or |
161 // the security level would be NONE. | 190 // the security level would be NONE. |
162 scoped_refptr<net::X509Certificate> cert; | 191 scoped_refptr<net::X509Certificate> cert; |
163 content::CertStore::GetInstance()->RetrieveCert( | 192 content::CertStore::GetInstance()->RetrieveCert( |
164 GetNavigationController()->GetVisibleEntry()->GetSSL().cert_id, &cert); | 193 GetNavigationController()->GetVisibleEntry()->GetSSL().cert_id, &cert); |
165 | 194 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 | 276 |
248 // Otherwise, extract search terms for HTTPS pages that do not have a security | 277 // Otherwise, extract search terms for HTTPS pages that do not have a security |
249 // error. | 278 // error. |
250 SecurityStateModel::SecurityLevel security_level = | 279 SecurityStateModel::SecurityLevel security_level = |
251 GetSecurityLevel(ignore_editing); | 280 GetSecurityLevel(ignore_editing); |
252 return ((security_level == SecurityStateModel::NONE) || | 281 return ((security_level == SecurityStateModel::NONE) || |
253 (security_level == SecurityStateModel::SECURITY_ERROR)) | 282 (security_level == SecurityStateModel::SECURITY_ERROR)) |
254 ? base::string16() | 283 ? base::string16() |
255 : search_terms; | 284 : search_terms; |
256 } | 285 } |
OLD | NEW |