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

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_model_impl.cc

Issue 1169213006: Make ConnectionSecurityHelper a namespace instead of a class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 6 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 "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/autocomplete_classifier.h" 10 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
11 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" 11 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
12 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" 12 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/search/search.h" 14 #include "chrome/browser/search/search.h"
15 #include "chrome/browser/ssl/connection_security_helper.h" 15 #include "chrome/browser/ssl/connection_security.h"
16 #include "chrome/browser/ui/toolbar/toolbar_model_delegate.h" 16 #include "chrome/browser/ui/toolbar/toolbar_model_delegate.h"
17 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
18 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
19 #include "chrome/grit/generated_resources.h" 19 #include "chrome/grit/generated_resources.h"
20 #include "components/google/core/browser/google_util.h" 20 #include "components/google/core/browser/google_util.h"
21 #include "components/omnibox/autocomplete_input.h" 21 #include "components/omnibox/autocomplete_input.h"
22 #include "components/omnibox/autocomplete_match.h" 22 #include "components/omnibox/autocomplete_match.h"
23 #include "content/public/browser/cert_store.h" 23 #include "content/public/browser/cert_store.h"
24 #include "content/public/browser/navigation_controller.h" 24 #include "content/public/browser/navigation_controller.h"
25 #include "content/public/browser/navigation_entry.h" 25 #include "content/public/browser/navigation_entry.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 102 }
103 103
104 return GURL(url::kAboutBlankURL); 104 return GURL(url::kAboutBlankURL);
105 } 105 }
106 106
107 bool ToolbarModelImpl::WouldPerformSearchTermReplacement( 107 bool ToolbarModelImpl::WouldPerformSearchTermReplacement(
108 bool ignore_editing) const { 108 bool ignore_editing) const {
109 return !GetSearchTerms(ignore_editing).empty(); 109 return !GetSearchTerms(ignore_editing).empty();
110 } 110 }
111 111
112 ConnectionSecurityHelper::SecurityLevel ToolbarModelImpl::GetSecurityLevel( 112 connection_security::SecurityLevel ToolbarModelImpl::GetSecurityLevel(
113 bool ignore_editing) const { 113 bool ignore_editing) const {
114 // When editing, assume no security style. 114 // When editing, assume no security style.
115 return (input_in_progress() && !ignore_editing) 115 return (input_in_progress() && !ignore_editing)
116 ? ConnectionSecurityHelper::NONE 116 ? connection_security::NONE
117 : ConnectionSecurityHelper::GetSecurityLevelForWebContents( 117 : connection_security::GetSecurityLevelForWebContents(
118 delegate_->GetActiveWebContents()); 118 delegate_->GetActiveWebContents());
119 } 119 }
120 120
121 int ToolbarModelImpl::GetIcon() const { 121 int ToolbarModelImpl::GetIcon() const {
122 if (WouldPerformSearchTermReplacement(false)) 122 if (WouldPerformSearchTermReplacement(false))
123 return IDR_OMNIBOX_SEARCH_SECURED; 123 return IDR_OMNIBOX_SEARCH_SECURED;
124 124
125 return GetIconForSecurityLevel(GetSecurityLevel(false)); 125 return GetIconForSecurityLevel(GetSecurityLevel(false));
126 } 126 }
127 127
128 int ToolbarModelImpl::GetIconForSecurityLevel( 128 int ToolbarModelImpl::GetIconForSecurityLevel(
129 ConnectionSecurityHelper::SecurityLevel level) const { 129 connection_security::SecurityLevel level) const {
130 switch (level) { 130 switch (level) {
131 case ConnectionSecurityHelper::NONE: 131 case connection_security::NONE:
132 return IDR_LOCATION_BAR_HTTP; 132 return IDR_LOCATION_BAR_HTTP;
133 case ConnectionSecurityHelper::EV_SECURE: 133 case connection_security::EV_SECURE:
134 case ConnectionSecurityHelper::SECURE: 134 case connection_security::SECURE:
135 return IDR_OMNIBOX_HTTPS_VALID; 135 return IDR_OMNIBOX_HTTPS_VALID;
136 case ConnectionSecurityHelper::SECURITY_WARNING: 136 case connection_security::SECURITY_WARNING:
137 return IDR_OMNIBOX_HTTPS_WARNING; 137 return IDR_OMNIBOX_HTTPS_WARNING;
138 case ConnectionSecurityHelper::SECURITY_POLICY_WARNING: 138 case connection_security::SECURITY_POLICY_WARNING:
139 return IDR_OMNIBOX_HTTPS_POLICY_WARNING; 139 return IDR_OMNIBOX_HTTPS_POLICY_WARNING;
140 case ConnectionSecurityHelper::SECURITY_ERROR: 140 case connection_security::SECURITY_ERROR:
141 return IDR_OMNIBOX_HTTPS_INVALID; 141 return IDR_OMNIBOX_HTTPS_INVALID;
142 } 142 }
143 143
144 NOTREACHED(); 144 NOTREACHED();
145 return IDR_LOCATION_BAR_HTTP; 145 return IDR_LOCATION_BAR_HTTP;
146 } 146 }
147 147
148 base::string16 ToolbarModelImpl::GetEVCertName() const { 148 base::string16 ToolbarModelImpl::GetEVCertName() const {
149 if (GetSecurityLevel(false) != ConnectionSecurityHelper::EV_SECURE) 149 if (GetSecurityLevel(false) != connection_security::EV_SECURE)
150 return base::string16(); 150 return base::string16();
151 151
152 // Note: Navigation controller and active entry are guaranteed non-NULL or 152 // Note: Navigation controller and active entry are guaranteed non-NULL or
153 // the security level would be NONE. 153 // the security level would be NONE.
154 scoped_refptr<net::X509Certificate> cert; 154 scoped_refptr<net::X509Certificate> cert;
155 content::CertStore::GetInstance()->RetrieveCert( 155 content::CertStore::GetInstance()->RetrieveCert(
156 GetNavigationController()->GetVisibleEntry()->GetSSL().cert_id, &cert); 156 GetNavigationController()->GetVisibleEntry()->GetSSL().cert_id, &cert);
157 157
158 // EV are required to have an organization name and country. 158 // EV are required to have an organization name and country.
159 DCHECK(!cert->subject().organization_names.empty()); 159 DCHECK(!cert->subject().organization_names.empty());
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 return search_terms; 232 return search_terms;
233 233
234 // If the URL is using a Google base URL specified via the command line, we 234 // If the URL is using a Google base URL specified via the command line, we
235 // bypass the security check below. 235 // bypass the security check below.
236 if (entry && 236 if (entry &&
237 google_util::StartsWithCommandLineGoogleBaseURL(entry->GetVirtualURL())) 237 google_util::StartsWithCommandLineGoogleBaseURL(entry->GetVirtualURL()))
238 return search_terms; 238 return search_terms;
239 239
240 // Otherwise, extract search terms for HTTPS pages that do not have a security 240 // Otherwise, extract search terms for HTTPS pages that do not have a security
241 // error. 241 // error.
242 ConnectionSecurityHelper::SecurityLevel security_level = 242 connection_security::SecurityLevel security_level =
243 GetSecurityLevel(ignore_editing); 243 GetSecurityLevel(ignore_editing);
244 return ((security_level == ConnectionSecurityHelper::NONE) || 244 return ((security_level == connection_security::NONE) ||
245 (security_level == ConnectionSecurityHelper::SECURITY_ERROR)) 245 (security_level == connection_security::SECURITY_ERROR))
246 ? base::string16() 246 ? base::string16()
247 : search_terms; 247 : search_terms;
248 } 248 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/toolbar_model_impl.h ('k') | chrome/browser/ui/views/location_bar/location_bar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698