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

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

Issue 1169213006: Make ConnectionSecurityHelper a namespace instead of a class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename namespace to connection_security 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.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 connection_security::SecurityLevel GetSecurityLevelForNonSecureFieldTrial() {
34 GetSecurityLevelForNonSecureFieldTrial() {
35 std::string choice = 34 std::string choice =
36 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 35 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
37 switches::kMarkNonSecureAs); 36 switches::kMarkNonSecureAs);
38 if (choice == switches::kMarkNonSecureAsNeutral) 37 if (choice == switches::kMarkNonSecureAsNeutral)
39 return ConnectionSecurityHelper::NONE; 38 return connection_security::NONE;
40 if (choice == switches::kMarkNonSecureAsDubious) 39 if (choice == switches::kMarkNonSecureAsDubious)
41 return ConnectionSecurityHelper::SECURITY_WARNING; 40 return connection_security::SECURITY_WARNING;
42 if (choice == switches::kMarkNonSecureAsNonSecure) 41 if (choice == switches::kMarkNonSecureAsNonSecure)
43 return ConnectionSecurityHelper::SECURITY_ERROR; 42 return connection_security::SECURITY_ERROR;
44 43
45 std::string group = base::FieldTrialList::FindFullName("MarkNonSecureAs"); 44 std::string group = base::FieldTrialList::FindFullName("MarkNonSecureAs");
46 if (group == switches::kMarkNonSecureAsNeutral) 45 if (group == switches::kMarkNonSecureAsNeutral)
47 return ConnectionSecurityHelper::NONE; 46 return connection_security::NONE;
48 if (group == switches::kMarkNonSecureAsDubious) 47 if (group == switches::kMarkNonSecureAsDubious)
49 return ConnectionSecurityHelper::SECURITY_WARNING; 48 return connection_security::SECURITY_WARNING;
50 if (group == switches::kMarkNonSecureAsNonSecure) 49 if (group == switches::kMarkNonSecureAsNonSecure)
51 return ConnectionSecurityHelper::SECURITY_ERROR; 50 return connection_security::SECURITY_ERROR;
52 51
53 return ConnectionSecurityHelper::NONE; 52 return connection_security::NONE;
54 } 53 }
55 54
56 } // namespace 55 } // namespace
57 56
58 ConnectionSecurityHelper::SecurityLevel 57 namespace connection_security {
59 ConnectionSecurityHelper::GetSecurityLevelForWebContents( 58
59 SecurityLevel GetSecurityLevelForWebContents(
60 const content::WebContents* web_contents) { 60 const content::WebContents* web_contents) {
61 if (!web_contents) 61 if (!web_contents)
62 return NONE; 62 return NONE;
63 63
64 content::NavigationEntry* entry = 64 content::NavigationEntry* entry =
65 web_contents->GetController().GetVisibleEntry(); 65 web_contents->GetController().GetVisibleEntry();
66 if (!entry) 66 if (!entry)
67 return NONE; 67 return NONE;
68 68
69 const content::SSLStatus& ssl = entry->GetSSL(); 69 const content::SSLStatus& ssl = entry->GetSSL();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 return EV_SECURE; 122 return EV_SECURE;
123 return SECURE; 123 return SECURE;
124 } 124 }
125 125
126 default: 126 default:
127 NOTREACHED(); 127 NOTREACHED();
128 return NONE; 128 return NONE;
129 } 129 }
130 } 130 }
131 131
132 content::SecurityStyle ConnectionSecurityHelper::GetSecurityStyleForWebContents( 132 content::SecurityStyle GetSecurityStyleForWebContents(
133 const content::WebContents* web_contents) { 133 const content::WebContents* web_contents) {
134 SecurityLevel security_level = GetSecurityLevelForWebContents(web_contents); 134 SecurityLevel security_level = GetSecurityLevelForWebContents(web_contents);
135 135
136 switch (security_level) { 136 switch (security_level) {
137 case NONE: 137 case NONE:
138 return content::SECURITY_STYLE_UNAUTHENTICATED; 138 return content::SECURITY_STYLE_UNAUTHENTICATED;
139 case EV_SECURE: 139 case EV_SECURE:
140 case SECURE: 140 case SECURE:
141 return content::SECURITY_STYLE_AUTHENTICATED; 141 return content::SECURITY_STYLE_AUTHENTICATED;
142 case SECURITY_WARNING: 142 case SECURITY_WARNING:
143 case SECURITY_POLICY_WARNING: 143 case SECURITY_POLICY_WARNING:
144 return content::SECURITY_STYLE_WARNING; 144 return content::SECURITY_STYLE_WARNING;
145 case SECURITY_ERROR: 145 case SECURITY_ERROR:
146 return content::SECURITY_STYLE_AUTHENTICATION_BROKEN; 146 return content::SECURITY_STYLE_AUTHENTICATION_BROKEN;
147 } 147 }
148 148
149 NOTREACHED(); 149 NOTREACHED();
150 return content::SECURITY_STYLE_UNKNOWN; 150 return content::SECURITY_STYLE_UNKNOWN;
151 } 151 }
152
153 } // namespace connection_security
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698