Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Side by Side Diff: components/toolbar/toolbar_model_impl.cc

Issue 2365263006: Delete pre-MD code from OmniboxResultView (Closed)
Patch Set: rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
12 #include "components/prefs/pref_service.h" 11 #include "components/prefs/pref_service.h"
13 #include "components/security_state/security_state_model.h" 12 #include "components/security_state/security_state_model.h"
14 #include "components/strings/grit/components_strings.h" 13 #include "components/strings/grit/components_strings.h"
15 #include "components/toolbar/toolbar_model_delegate.h" 14 #include "components/toolbar/toolbar_model_delegate.h"
16 #include "components/url_formatter/elide_url.h" 15 #include "components/url_formatter/elide_url.h"
17 #include "components/url_formatter/url_formatter.h" 16 #include "components/url_formatter/url_formatter.h"
18 #include "net/cert/cert_status_flags.h" 17 #include "net/cert/cert_status_flags.h"
19 #include "net/cert/x509_certificate.h" 18 #include "net/cert/x509_certificate.h"
20 #include "net/ssl/ssl_connection_status_flags.h" 19 #include "net/ssl/ssl_connection_status_flags.h"
21 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } 62 }
64 63
65 SecurityStateModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel( 64 SecurityStateModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel(
66 bool ignore_editing) const { 65 bool ignore_editing) const {
67 // When editing or empty, assume no security style. 66 // When editing or empty, assume no security style.
68 return ((input_in_progress() && !ignore_editing) || !ShouldDisplayURL()) 67 return ((input_in_progress() && !ignore_editing) || !ShouldDisplayURL())
69 ? SecurityStateModel::NONE 68 ? SecurityStateModel::NONE
70 : delegate_->GetSecurityLevel(); 69 : delegate_->GetSecurityLevel();
71 } 70 }
72 71
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
94 gfx::VectorIconId ToolbarModelImpl::GetVectorIcon() const { 72 gfx::VectorIconId ToolbarModelImpl::GetVectorIcon() const {
95 #if !defined(OS_ANDROID) && !defined(OS_IOS) 73 #if !defined(OS_ANDROID) && !defined(OS_IOS)
Peter Kasting 2016/10/06 04:45:36 The fact that this #if is still here makes me worr
Evan Stade 2016/10/06 15:16:37 yea, I wasn't sure either but I got green try runs
96 switch (GetSecurityLevel(false)) { 74 switch (GetSecurityLevel(false)) {
97 case SecurityStateModel::NONE: 75 case SecurityStateModel::NONE:
98 case SecurityStateModel::HTTP_SHOW_WARNING: 76 case SecurityStateModel::HTTP_SHOW_WARNING:
99 return gfx::VectorIconId::LOCATION_BAR_HTTP; 77 return gfx::VectorIconId::LOCATION_BAR_HTTP;
100 case SecurityStateModel::EV_SECURE: 78 case SecurityStateModel::EV_SECURE:
101 case SecurityStateModel::SECURE: 79 case SecurityStateModel::SECURE:
102 return gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID; 80 return gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID;
103 case SecurityStateModel::SECURITY_WARNING: 81 case SecurityStateModel::SECURITY_WARNING:
104 // Surface Dubious as Neutral. 82 // Surface Dubious as Neutral.
105 return gfx::VectorIconId::LOCATION_BAR_HTTP; 83 return gfx::VectorIconId::LOCATION_BAR_HTTP;
106 case SecurityStateModel::SECURE_WITH_POLICY_INSTALLED_CERT: 84 case SecurityStateModel::SECURE_WITH_POLICY_INSTALLED_CERT:
107 return gfx::VectorIconId::BUSINESS; 85 return gfx::VectorIconId::BUSINESS;
108 case SecurityStateModel::DANGEROUS: 86 case SecurityStateModel::DANGEROUS:
109 return gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID; 87 return gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID;
110 } 88 }
111 #endif 89 #endif
112
113 NOTREACHED(); 90 NOTREACHED();
114 return gfx::VectorIconId::VECTOR_ICON_NONE; 91 return gfx::VectorIconId::VECTOR_ICON_NONE;
115 } 92 }
116 93
117 base::string16 ToolbarModelImpl::GetEVCertName() const { 94 base::string16 ToolbarModelImpl::GetEVCertName() const {
118 if (GetSecurityLevel(false) != SecurityStateModel::EV_SECURE) 95 if (GetSecurityLevel(false) != SecurityStateModel::EV_SECURE)
119 return base::string16(); 96 return base::string16();
120 97
121 // Note: cert is guaranteed non-NULL or the security level would be NONE. 98 // Note: cert is guaranteed non-NULL or the security level would be NONE.
122 scoped_refptr<net::X509Certificate> cert = delegate_->GetCertificate(); 99 scoped_refptr<net::X509Certificate> cert = delegate_->GetCertificate();
(...skipping 17 matching lines...) Expand all
140 ? IDS_DANGEROUS_VERBOSE_STATE 117 ? IDS_DANGEROUS_VERBOSE_STATE
141 : IDS_NOT_SECURE_VERBOSE_STATE); 118 : IDS_NOT_SECURE_VERBOSE_STATE);
142 default: 119 default:
143 return base::string16(); 120 return base::string16();
144 } 121 }
145 } 122 }
146 123
147 bool ToolbarModelImpl::ShouldDisplayURL() const { 124 bool ToolbarModelImpl::ShouldDisplayURL() const {
148 return delegate_->ShouldDisplayURL(); 125 return delegate_->ShouldDisplayURL();
149 } 126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698