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

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

Issue 1169213006: Make ConnectionSecurityHelper a namespace instead of a class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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/connection_security_helper.h" 5 #include "chrome/browser/ssl/connection_security_status.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ssl/ssl_error_info.h" 11 #include "chrome/browser/ssl/ssl_error_info.h"
12 #include "chrome/common/chrome_constants.h" 12 #include "chrome/common/chrome_constants.h"
13 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
15 #include "content/public/browser/cert_store.h" 15 #include "content/public/browser/cert_store.h"
16 #include "content/public/browser/navigation_controller.h" 16 #include "content/public/browser/navigation_controller.h"
17 #include "content/public/browser/navigation_entry.h" 17 #include "content/public/browser/navigation_entry.h"
18 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
19 #include "content/public/common/origin_util.h" 19 #include "content/public/common/origin_util.h"
20 #include "content/public/common/ssl_status.h" 20 #include "content/public/common/ssl_status.h"
21 #include "net/base/net_util.h" 21 #include "net/base/net_util.h"
22 #include "net/cert/cert_status_flags.h" 22 #include "net/cert/cert_status_flags.h"
23 #include "net/cert/x509_certificate.h" 23 #include "net/cert/x509_certificate.h"
24 #include "net/ssl/ssl_connection_status_flags.h" 24 #include "net/ssl/ssl_connection_status_flags.h"
25 25
26 #if defined(OS_CHROMEOS) 26 #if defined(OS_CHROMEOS)
27 #include "chrome/browser/chromeos/policy/policy_cert_service.h" 27 #include "chrome/browser/chromeos/policy/policy_cert_service.h"
28 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" 28 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
29 #endif 29 #endif
30 30
31 namespace { 31 namespace {
32 32
33 ConnectionSecurityHelper::SecurityLevel 33 ConnectionSecurityStatus::SecurityLevel
34 GetSecurityLevelForNonSecureFieldTrial() { 34 GetSecurityLevelForNonSecureFieldTrial() {
35 std::string choice = 35 std::string choice =
36 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 36 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
37 switches::kMarkNonSecureAs); 37 switches::kMarkNonSecureAs);
38 if (choice == switches::kMarkNonSecureAsNeutral) 38 if (choice == switches::kMarkNonSecureAsNeutral)
39 return ConnectionSecurityHelper::NONE; 39 return ConnectionSecurityStatus::NONE;
40 if (choice == switches::kMarkNonSecureAsDubious) 40 if (choice == switches::kMarkNonSecureAsDubious)
41 return ConnectionSecurityHelper::SECURITY_WARNING; 41 return ConnectionSecurityStatus::SECURITY_WARNING;
42 if (choice == switches::kMarkNonSecureAsNonSecure) 42 if (choice == switches::kMarkNonSecureAsNonSecure)
43 return ConnectionSecurityHelper::SECURITY_ERROR; 43 return ConnectionSecurityStatus::SECURITY_ERROR;
44 44
45 std::string group = base::FieldTrialList::FindFullName("MarkNonSecureAs"); 45 std::string group = base::FieldTrialList::FindFullName("MarkNonSecureAs");
46 if (group == switches::kMarkNonSecureAsNeutral) 46 if (group == switches::kMarkNonSecureAsNeutral)
47 return ConnectionSecurityHelper::NONE; 47 return ConnectionSecurityStatus::NONE;
48 if (group == switches::kMarkNonSecureAsDubious) 48 if (group == switches::kMarkNonSecureAsDubious)
49 return ConnectionSecurityHelper::SECURITY_WARNING; 49 return ConnectionSecurityStatus::SECURITY_WARNING;
50 if (group == switches::kMarkNonSecureAsNonSecure) 50 if (group == switches::kMarkNonSecureAsNonSecure)
51 return ConnectionSecurityHelper::SECURITY_ERROR; 51 return ConnectionSecurityStatus::SECURITY_ERROR;
52 52
53 return ConnectionSecurityHelper::NONE; 53 return ConnectionSecurityStatus::NONE;
54 } 54 }
55 55
56 } // namespace 56 } // namespace
57 57
58 ConnectionSecurityHelper::SecurityLevel 58 namespace ConnectionSecurityStatus {
59 ConnectionSecurityHelper::GetSecurityLevelForWebContents( 59
60 SecurityLevel GetSecurityLevelForWebContents(
60 const content::WebContents* web_contents) { 61 const content::WebContents* web_contents) {
61 if (!web_contents) 62 if (!web_contents)
62 return NONE; 63 return NONE;
63 64
64 content::NavigationEntry* entry = 65 content::NavigationEntry* entry =
65 web_contents->GetController().GetVisibleEntry(); 66 web_contents->GetController().GetVisibleEntry();
66 if (!entry) 67 if (!entry)
67 return NONE; 68 return NONE;
68 69
69 const content::SSLStatus& ssl = entry->GetSSL(); 70 const content::SSLStatus& ssl = entry->GetSSL();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 return EV_SECURE; 123 return EV_SECURE;
123 return SECURE; 124 return SECURE;
124 } 125 }
125 126
126 default: 127 default:
127 NOTREACHED(); 128 NOTREACHED();
128 return NONE; 129 return NONE;
129 } 130 }
130 } 131 }
131 132
132 content::SecurityStyle ConnectionSecurityHelper::GetSecurityStyleForWebContents( 133 content::SecurityStyle GetSecurityStyleForWebContents(
133 const content::WebContents* web_contents) { 134 const content::WebContents* web_contents) {
134 SecurityLevel security_level = GetSecurityLevelForWebContents(web_contents); 135 SecurityLevel security_level = GetSecurityLevelForWebContents(web_contents);
135 136
136 switch (security_level) { 137 switch (security_level) {
137 case NONE: 138 case NONE:
138 return content::SECURITY_STYLE_UNAUTHENTICATED; 139 return content::SECURITY_STYLE_UNAUTHENTICATED;
139 case EV_SECURE: 140 case EV_SECURE:
140 case SECURE: 141 case SECURE:
141 return content::SECURITY_STYLE_AUTHENTICATED; 142 return content::SECURITY_STYLE_AUTHENTICATED;
142 case SECURITY_WARNING: 143 case SECURITY_WARNING:
143 case SECURITY_POLICY_WARNING: 144 case SECURITY_POLICY_WARNING:
144 return content::SECURITY_STYLE_WARNING; 145 return content::SECURITY_STYLE_WARNING;
145 case SECURITY_ERROR: 146 case SECURITY_ERROR:
146 return content::SECURITY_STYLE_AUTHENTICATION_BROKEN; 147 return content::SECURITY_STYLE_AUTHENTICATION_BROKEN;
147 } 148 }
148 149
149 NOTREACHED(); 150 NOTREACHED();
150 return content::SECURITY_STYLE_UNKNOWN; 151 return content::SECURITY_STYLE_UNKNOWN;
151 } 152 }
153
154 } // namespace ConnectionSecurityStatus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698