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 "components/toolbar/toolbar_model_impl.h" | 5 #include "components/toolbar/toolbar_model_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.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 "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "components/grit/components_scaled_resources.h" |
11 #include "components/prefs/pref_service.h" | 12 #include "components/prefs/pref_service.h" |
12 #include "components/security_state/security_state_model.h" | 13 #include "components/security_state/security_state_model.h" |
13 #include "components/strings/grit/components_strings.h" | 14 #include "components/strings/grit/components_strings.h" |
14 #include "components/toolbar/toolbar_model_delegate.h" | 15 #include "components/toolbar/toolbar_model_delegate.h" |
15 #include "components/url_formatter/elide_url.h" | 16 #include "components/url_formatter/elide_url.h" |
16 #include "components/url_formatter/url_formatter.h" | 17 #include "components/url_formatter/url_formatter.h" |
17 #include "net/cert/cert_status_flags.h" | 18 #include "net/cert/cert_status_flags.h" |
18 #include "net/cert/x509_certificate.h" | 19 #include "net/cert/x509_certificate.h" |
19 #include "net/ssl/ssl_connection_status_flags.h" | 20 #include "net/ssl/ssl_connection_status_flags.h" |
20 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 } | 63 } |
63 | 64 |
64 SecurityStateModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel( | 65 SecurityStateModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel( |
65 bool ignore_editing) const { | 66 bool ignore_editing) const { |
66 // When editing or empty, assume no security style. | 67 // When editing or empty, assume no security style. |
67 return ((input_in_progress() && !ignore_editing) || !ShouldDisplayURL()) | 68 return ((input_in_progress() && !ignore_editing) || !ShouldDisplayURL()) |
68 ? SecurityStateModel::NONE | 69 ? SecurityStateModel::NONE |
69 : delegate_->GetSecurityLevel(); | 70 : delegate_->GetSecurityLevel(); |
70 } | 71 } |
71 | 72 |
| 73 int ToolbarModelImpl::GetIcon() const { |
| 74 switch (GetSecurityLevel(false)) { |
| 75 case SecurityStateModel::NONE: |
| 76 case SecurityStateModel::HTTP_SHOW_WARNING: |
| 77 return IDR_LOCATION_BAR_HTTP; |
| 78 case SecurityStateModel::EV_SECURE: |
| 79 case SecurityStateModel::SECURE: |
| 80 return IDR_OMNIBOX_HTTPS_VALID; |
| 81 case SecurityStateModel::SECURITY_WARNING: |
| 82 // Surface Dubious as Neutral. |
| 83 return IDR_LOCATION_BAR_HTTP; |
| 84 case SecurityStateModel::SECURE_WITH_POLICY_INSTALLED_CERT: |
| 85 return IDR_OMNIBOX_HTTPS_POLICY_WARNING; |
| 86 case SecurityStateModel::DANGEROUS: |
| 87 return IDR_OMNIBOX_HTTPS_INVALID; |
| 88 } |
| 89 |
| 90 NOTREACHED(); |
| 91 return IDR_LOCATION_BAR_HTTP; |
| 92 } |
| 93 |
72 gfx::VectorIconId ToolbarModelImpl::GetVectorIcon() const { | 94 gfx::VectorIconId ToolbarModelImpl::GetVectorIcon() const { |
73 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 95 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
74 switch (GetSecurityLevel(false)) { | 96 switch (GetSecurityLevel(false)) { |
75 case SecurityStateModel::NONE: | 97 case SecurityStateModel::NONE: |
76 case SecurityStateModel::HTTP_SHOW_WARNING: | 98 case SecurityStateModel::HTTP_SHOW_WARNING: |
77 return gfx::VectorIconId::LOCATION_BAR_HTTP; | 99 return gfx::VectorIconId::LOCATION_BAR_HTTP; |
78 case SecurityStateModel::EV_SECURE: | 100 case SecurityStateModel::EV_SECURE: |
79 case SecurityStateModel::SECURE: | 101 case SecurityStateModel::SECURE: |
80 return gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID; | 102 return gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID; |
81 case SecurityStateModel::SECURITY_WARNING: | 103 case SecurityStateModel::SECURITY_WARNING: |
82 // Surface Dubious as Neutral. | 104 // Surface Dubious as Neutral. |
83 return gfx::VectorIconId::LOCATION_BAR_HTTP; | 105 return gfx::VectorIconId::LOCATION_BAR_HTTP; |
84 case SecurityStateModel::SECURE_WITH_POLICY_INSTALLED_CERT: | 106 case SecurityStateModel::SECURE_WITH_POLICY_INSTALLED_CERT: |
85 return gfx::VectorIconId::BUSINESS; | 107 return gfx::VectorIconId::BUSINESS; |
86 case SecurityStateModel::DANGEROUS: | 108 case SecurityStateModel::DANGEROUS: |
87 return gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID; | 109 return gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID; |
88 } | 110 } |
89 #endif | 111 #endif |
| 112 |
90 NOTREACHED(); | 113 NOTREACHED(); |
91 return gfx::VectorIconId::VECTOR_ICON_NONE; | 114 return gfx::VectorIconId::VECTOR_ICON_NONE; |
92 } | 115 } |
93 | 116 |
94 base::string16 ToolbarModelImpl::GetEVCertName() const { | 117 base::string16 ToolbarModelImpl::GetEVCertName() const { |
95 if (GetSecurityLevel(false) != SecurityStateModel::EV_SECURE) | 118 if (GetSecurityLevel(false) != SecurityStateModel::EV_SECURE) |
96 return base::string16(); | 119 return base::string16(); |
97 | 120 |
98 // Note: cert is guaranteed non-NULL or the security level would be NONE. | 121 // Note: cert is guaranteed non-NULL or the security level would be NONE. |
99 scoped_refptr<net::X509Certificate> cert = delegate_->GetCertificate(); | 122 scoped_refptr<net::X509Certificate> cert = delegate_->GetCertificate(); |
(...skipping 17 matching lines...) Expand all Loading... |
117 ? IDS_DANGEROUS_VERBOSE_STATE | 140 ? IDS_DANGEROUS_VERBOSE_STATE |
118 : IDS_NOT_SECURE_VERBOSE_STATE); | 141 : IDS_NOT_SECURE_VERBOSE_STATE); |
119 default: | 142 default: |
120 return base::string16(); | 143 return base::string16(); |
121 } | 144 } |
122 } | 145 } |
123 | 146 |
124 bool ToolbarModelImpl::ShouldDisplayURL() const { | 147 bool ToolbarModelImpl::ShouldDisplayURL() const { |
125 return delegate_->ShouldDisplayURL(); | 148 return delegate_->ShouldDisplayURL(); |
126 } | 149 } |
OLD | NEW |