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 17 matching lines...) Expand all Loading... |
28 #include "content/public/browser/web_ui.h" | 28 #include "content/public/browser/web_ui.h" |
29 #include "content/public/common/content_constants.h" | 29 #include "content/public/common/content_constants.h" |
30 #include "content/public/common/ssl_status.h" | 30 #include "content/public/common/ssl_status.h" |
31 #include "grit/components_scaled_resources.h" | 31 #include "grit/components_scaled_resources.h" |
32 #include "grit/theme_resources.h" | 32 #include "grit/theme_resources.h" |
33 #include "net/cert/cert_status_flags.h" | 33 #include "net/cert/cert_status_flags.h" |
34 #include "net/cert/x509_certificate.h" | 34 #include "net/cert/x509_certificate.h" |
35 #include "net/ssl/ssl_connection_status_flags.h" | 35 #include "net/ssl/ssl_connection_status_flags.h" |
36 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
37 #include "ui/gfx/text_elider.h" | 37 #include "ui/gfx/text_elider.h" |
| 38 #include "ui/gfx/vector_icons_public.h" |
38 | 39 |
39 using content::NavigationController; | 40 using content::NavigationController; |
40 using content::NavigationEntry; | 41 using content::NavigationEntry; |
41 using content::WebContents; | 42 using content::WebContents; |
42 | 43 |
43 ToolbarModelImpl::ToolbarModelImpl(ToolbarModelDelegate* delegate) | 44 ToolbarModelImpl::ToolbarModelImpl(ToolbarModelDelegate* delegate) |
44 : delegate_(delegate) { | 45 : delegate_(delegate) { |
45 } | 46 } |
46 | 47 |
47 ToolbarModelImpl::~ToolbarModelImpl() { | 48 ToolbarModelImpl::~ToolbarModelImpl() { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 const SecurityStateModel* model = | 132 const SecurityStateModel* model = |
132 SecurityStateModel::FromWebContents(web_contents); | 133 SecurityStateModel::FromWebContents(web_contents); |
133 | 134 |
134 // When editing, assume no security style. | 135 // When editing, assume no security style. |
135 return (input_in_progress() && !ignore_editing) | 136 return (input_in_progress() && !ignore_editing) |
136 ? SecurityStateModel::NONE | 137 ? SecurityStateModel::NONE |
137 : model->GetSecurityInfo().security_level; | 138 : model->GetSecurityInfo().security_level; |
138 } | 139 } |
139 | 140 |
140 int ToolbarModelImpl::GetIcon() const { | 141 int ToolbarModelImpl::GetIcon() const { |
141 if (WouldPerformSearchTermReplacement(false)) | 142 switch (GetSecurityLevel(false)) { |
142 return IDR_OMNIBOX_SEARCH_SECURED; | |
143 | |
144 return GetIconForSecurityLevel(GetSecurityLevel(false)); | |
145 } | |
146 | |
147 int ToolbarModelImpl::GetIconForSecurityLevel( | |
148 SecurityStateModel::SecurityLevel level) const { | |
149 switch (level) { | |
150 case SecurityStateModel::NONE: | 143 case SecurityStateModel::NONE: |
151 return IDR_LOCATION_BAR_HTTP; | 144 return IDR_LOCATION_BAR_HTTP; |
152 case SecurityStateModel::EV_SECURE: | 145 case SecurityStateModel::EV_SECURE: |
153 case SecurityStateModel::SECURE: | 146 case SecurityStateModel::SECURE: |
154 return IDR_OMNIBOX_HTTPS_VALID; | 147 return IDR_OMNIBOX_HTTPS_VALID; |
155 case SecurityStateModel::SECURITY_WARNING: | 148 case SecurityStateModel::SECURITY_WARNING: |
156 // Surface Dubious as Neutral. | 149 // Surface Dubious as Neutral. |
157 return IDR_LOCATION_BAR_HTTP; | 150 return IDR_LOCATION_BAR_HTTP; |
158 case SecurityStateModel::SECURITY_POLICY_WARNING: | 151 case SecurityStateModel::SECURITY_POLICY_WARNING: |
159 return IDR_OMNIBOX_HTTPS_POLICY_WARNING; | 152 return IDR_OMNIBOX_HTTPS_POLICY_WARNING; |
160 case SecurityStateModel::SECURITY_ERROR: | 153 case SecurityStateModel::SECURITY_ERROR: |
161 return IDR_OMNIBOX_HTTPS_INVALID; | 154 return IDR_OMNIBOX_HTTPS_INVALID; |
162 } | 155 } |
163 | 156 |
164 NOTREACHED(); | 157 NOTREACHED(); |
165 return IDR_LOCATION_BAR_HTTP; | 158 return IDR_LOCATION_BAR_HTTP; |
166 } | 159 } |
167 | 160 |
| 161 gfx::VectorIconId ToolbarModelImpl::GetVectorIcon() const { |
| 162 #if !defined(OS_ANDROID) && !defined(OS_MACOSX) && !defined(OS_IOS) |
| 163 switch (GetSecurityLevel(false)) { |
| 164 case SecurityStateModel::NONE: |
| 165 return gfx::VectorIconId::LOCATION_BAR_HTTP; |
| 166 case SecurityStateModel::EV_SECURE: |
| 167 case SecurityStateModel::SECURE: |
| 168 return gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID; |
| 169 case SecurityStateModel::SECURITY_WARNING: |
| 170 // Surface Dubious as Neutral. |
| 171 return gfx::VectorIconId::LOCATION_BAR_HTTP; |
| 172 case SecurityStateModel::SECURITY_POLICY_WARNING: |
| 173 return gfx::VectorIconId::BUSINESS; |
| 174 case SecurityStateModel::SECURITY_ERROR: |
| 175 return gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID; |
| 176 } |
| 177 #endif |
| 178 |
| 179 NOTREACHED(); |
| 180 return gfx::VectorIconId::VECTOR_ICON_NONE; |
| 181 } |
| 182 |
168 base::string16 ToolbarModelImpl::GetEVCertName() const { | 183 base::string16 ToolbarModelImpl::GetEVCertName() const { |
169 if (GetSecurityLevel(false) != SecurityStateModel::EV_SECURE) | 184 if (GetSecurityLevel(false) != SecurityStateModel::EV_SECURE) |
170 return base::string16(); | 185 return base::string16(); |
171 | 186 |
172 // Note: Navigation controller and active entry are guaranteed non-NULL or | 187 // Note: Navigation controller and active entry are guaranteed non-NULL or |
173 // the security level would be NONE. | 188 // the security level would be NONE. |
174 scoped_refptr<net::X509Certificate> cert; | 189 scoped_refptr<net::X509Certificate> cert; |
175 content::CertStore::GetInstance()->RetrieveCert( | 190 content::CertStore::GetInstance()->RetrieveCert( |
176 GetNavigationController()->GetVisibleEntry()->GetSSL().cert_id, &cert); | 191 GetNavigationController()->GetVisibleEntry()->GetSSL().cert_id, &cert); |
177 | 192 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 274 |
260 // Otherwise, extract search terms for HTTPS pages that do not have a security | 275 // Otherwise, extract search terms for HTTPS pages that do not have a security |
261 // error. | 276 // error. |
262 SecurityStateModel::SecurityLevel security_level = | 277 SecurityStateModel::SecurityLevel security_level = |
263 GetSecurityLevel(ignore_editing); | 278 GetSecurityLevel(ignore_editing); |
264 return ((security_level == SecurityStateModel::NONE) || | 279 return ((security_level == SecurityStateModel::NONE) || |
265 (security_level == SecurityStateModel::SECURITY_ERROR)) | 280 (security_level == SecurityStateModel::SECURITY_ERROR)) |
266 ? base::string16() | 281 ? base::string16() |
267 : search_terms; | 282 : search_terms; |
268 } | 283 } |
OLD | NEW |