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

Side by Side Diff: chrome/browser/ssl/chrome_security_state_model_client.cc

Issue 2410043003: Add a console messsage for HTTP-bad (Closed)
Patch Set: 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
« no previous file with comments | « chrome/browser/ssl/chrome_security_state_model_client.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ssl/chrome_security_state_model_client.h" 5 #include "chrome/browser/ssl/chrome_security_state_model_client.h"
6 6
7 #include <openssl/ssl.h> 7 #include <openssl/ssl.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
13 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
14 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/chromeos/policy/policy_cert_service.h" 18 #include "chrome/browser/chromeos/policy/policy_cert_service.h"
19 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" 19 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
20 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 21 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
22 #include "chrome/browser/safe_browsing/ui_manager.h" 22 #include "chrome/browser/safe_browsing/ui_manager.h"
23 #include "chrome/grit/generated_resources.h" 23 #include "chrome/grit/generated_resources.h"
24 #include "content/public/browser/navigation_entry.h" 24 #include "content/public/browser/navigation_entry.h"
25 #include "content/public/browser/render_frame_host.h"
25 #include "content/public/browser/security_style_explanation.h" 26 #include "content/public/browser/security_style_explanation.h"
26 #include "content/public/browser/security_style_explanations.h" 27 #include "content/public/browser/security_style_explanations.h"
27 #include "content/public/browser/ssl_status.h" 28 #include "content/public/browser/ssl_status.h"
28 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
29 #include "content/public/common/origin_util.h" 30 #include "content/public/common/origin_util.h"
30 #include "net/base/net_errors.h" 31 #include "net/base/net_errors.h"
31 #include "net/cert/x509_certificate.h" 32 #include "net/cert/x509_certificate.h"
32 #include "net/ssl/ssl_cipher_suite_names.h" 33 #include "net/ssl/ssl_cipher_suite_names.h"
33 #include "net/ssl/ssl_connection_status_flags.h" 34 #include "net/ssl/ssl_connection_status_flags.h"
34 #include "ui/base/l10n/l10n_util.h" 35 #include "ui/base/l10n/l10n_util.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 g_browser_process->safe_browsing_service(); 154 g_browser_process->safe_browsing_service();
154 if (!sb_service) 155 if (!sb_service)
155 return; 156 return;
156 scoped_refptr<SafeBrowsingUIManager> sb_ui_manager = sb_service->ui_manager(); 157 scoped_refptr<SafeBrowsingUIManager> sb_ui_manager = sb_service->ui_manager();
157 if (sb_ui_manager->IsUrlWhitelistedOrPendingForWebContents( 158 if (sb_ui_manager->IsUrlWhitelistedOrPendingForWebContents(
158 entry->GetURL(), false, entry, web_contents, false)) { 159 entry->GetURL(), false, entry, web_contents, false)) {
159 state->fails_malware_check = true; 160 state->fails_malware_check = true;
160 } 161 }
161 } 162 }
162 163
164 // Logs a message to the console if the security level has been
165 // downgraded to HTTP_SHOW_WARNING. Returns true if the console message
166 // was logged, false otherwise.
167 bool MaybeLogHttpWarning(
168 content::WebContents* web_contents,
169 const security_state::SecurityStateModel::SecurityInfo* const
170 security_info) {
171 if (security_info->security_level ==
172 security_state::SecurityStateModel::HTTP_SHOW_WARNING) {
173 web_contents->GetMainFrame()->AddMessageToConsole(
174 content::CONSOLE_MESSAGE_LEVEL_WARNING,
175 base::StringPrintf("In Chrome M56 (Jan 2017), this page will be marked "
elawrence 2016/10/12 02:09:45 I'll betray my lack of understanding of Chrome's u
estark 2016/10/12 02:43:19 Err... that would be because I mindlessly based th
176 "as \"not secure\" in the URL bar. For more "
177 "information see https://goo.gl/zmWq3m"));
178 return true;
179 }
180 return false;
181 }
182
163 } // namespace 183 } // namespace
164 184
165 ChromeSecurityStateModelClient::ChromeSecurityStateModelClient( 185 ChromeSecurityStateModelClient::ChromeSecurityStateModelClient(
166 content::WebContents* web_contents) 186 content::WebContents* web_contents)
167 : web_contents_(web_contents), 187 : web_contents_(web_contents),
168 security_state_model_(new SecurityStateModel()) { 188 security_state_model_(new SecurityStateModel()),
189 logged_http_warning_on_current_navigation_(false) {
169 security_state_model_->SetClient(this); 190 security_state_model_->SetClient(this);
191 WebContentsObserver::Observe(web_contents_);
170 } 192 }
171 193
172 ChromeSecurityStateModelClient::~ChromeSecurityStateModelClient() {} 194 ChromeSecurityStateModelClient::~ChromeSecurityStateModelClient() {}
173 195
174 // static 196 // static
175 blink::WebSecurityStyle ChromeSecurityStateModelClient::GetSecurityStyle( 197 blink::WebSecurityStyle ChromeSecurityStateModelClient::GetSecurityStyle(
176 const security_state::SecurityStateModel::SecurityInfo& security_info, 198 const security_state::SecurityStateModel::SecurityInfo& security_info,
177 content::SecurityStyleExplanations* security_style_explanations) { 199 content::SecurityStyleExplanations* security_style_explanations) {
178 const blink::WebSecurityStyle security_style = 200 const blink::WebSecurityStyle security_style =
179 SecurityLevelToSecurityStyle(security_info.security_level); 201 SecurityLevelToSecurityStyle(security_info.security_level);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 "Public-Key Pinning Bypassed", 312 "Public-Key Pinning Bypassed",
291 "Public-key pinning was bypassed by a local root certificate.")); 313 "Public-key pinning was bypassed by a local root certificate."));
292 } 314 }
293 315
294 return security_style; 316 return security_style;
295 } 317 }
296 318
297 void ChromeSecurityStateModelClient::GetSecurityInfo( 319 void ChromeSecurityStateModelClient::GetSecurityInfo(
298 SecurityStateModel::SecurityInfo* result) const { 320 SecurityStateModel::SecurityInfo* result) const {
299 security_state_model_->GetSecurityInfo(result); 321 security_state_model_->GetSecurityInfo(result);
322 if (!logged_http_warning_on_current_navigation_) {
323 logged_http_warning_on_current_navigation_ =
324 MaybeLogHttpWarning(web_contents_, result);
325 }
300 } 326 }
301 327
302 bool ChromeSecurityStateModelClient::UsedPolicyInstalledCertificate() { 328 bool ChromeSecurityStateModelClient::UsedPolicyInstalledCertificate() {
303 #if defined(OS_CHROMEOS) 329 #if defined(OS_CHROMEOS)
304 policy::PolicyCertService* service = 330 policy::PolicyCertService* service =
305 policy::PolicyCertServiceFactory::GetForProfile( 331 policy::PolicyCertServiceFactory::GetForProfile(
306 Profile::FromBrowserContext(web_contents_->GetBrowserContext())); 332 Profile::FromBrowserContext(web_contents_->GetBrowserContext()));
307 if (service && service->UsedPolicyCertificates()) 333 if (service && service->UsedPolicyCertificates())
308 return true; 334 return true;
309 #endif 335 #endif
310 return false; 336 return false;
311 } 337 }
312 338
313 bool ChromeSecurityStateModelClient::IsOriginSecure(const GURL& url) { 339 bool ChromeSecurityStateModelClient::IsOriginSecure(const GURL& url) {
314 return content::IsOriginSecure(url); 340 return content::IsOriginSecure(url);
315 } 341 }
316 342
343 void ChromeSecurityStateModelClient::DidFinishNavigation(
344 content::NavigationHandle* navigation_handle) {
345 logged_http_warning_on_current_navigation_ = false;
346 }
347
317 void ChromeSecurityStateModelClient::GetVisibleSecurityState( 348 void ChromeSecurityStateModelClient::GetVisibleSecurityState(
318 SecurityStateModel::VisibleSecurityState* state) { 349 SecurityStateModel::VisibleSecurityState* state) {
319 content::NavigationEntry* entry = 350 content::NavigationEntry* entry =
320 web_contents_->GetController().GetVisibleEntry(); 351 web_contents_->GetController().GetVisibleEntry();
321 if (!entry) { 352 if (!entry) {
322 *state = SecurityStateModel::VisibleSecurityState(); 353 *state = SecurityStateModel::VisibleSecurityState();
323 return; 354 return;
324 } 355 }
325 356
326 if (!entry->GetSSL().initialized) { 357 if (!entry->GetSSL().initialized) {
(...skipping 28 matching lines...) Expand all
355 !!(ssl.content_status & content::SSLStatus::RAN_CONTENT_WITH_CERT_ERRORS); 386 !!(ssl.content_status & content::SSLStatus::RAN_CONTENT_WITH_CERT_ERRORS);
356 state->displayed_password_field_on_http = 387 state->displayed_password_field_on_http =
357 !!(ssl.content_status & 388 !!(ssl.content_status &
358 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); 389 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP);
359 state->displayed_credit_card_field_on_http = 390 state->displayed_credit_card_field_on_http =
360 !!(ssl.content_status & 391 !!(ssl.content_status &
361 content::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP); 392 content::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP);
362 393
363 CheckSafeBrowsingStatus(entry, web_contents_, state); 394 CheckSafeBrowsingStatus(entry, web_contents_, state);
364 } 395 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/chrome_security_state_model_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698