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

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

Issue 813873005: Add field trial and flag to mark HTTP as non-secure. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Only badge if SECURITY_STYLE_UNAUTHENTICATED && unauthenticated network transport. (E.g. not chrome… Created 6 years 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/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 "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 *level = ToolbarModel::SECURITY_ERROR; 58 *level = ToolbarModel::SECURITY_ERROR;
59 else if (group == "Warning") 59 else if (group == "Warning")
60 *level = ToolbarModel::SECURITY_WARNING; 60 *level = ToolbarModel::SECURITY_WARNING;
61 else if (group == "HTTP") 61 else if (group == "HTTP")
62 *level = ToolbarModel::NONE; 62 *level = ToolbarModel::NONE;
63 else 63 else
64 return false; 64 return false;
65 return true; 65 return true;
66 } 66 }
67 67
68 ToolbarModel::SecurityLevel GetSecurityLevelForHttpFieldTrial() {
69 std::string group = base::FieldTrialList::FindFullName("MarkHTTPAsNonSecure");
70 std::string choice = base::CommandLine::ForCurrentProcess()->
71 GetSwitchValueASCII(switches::kMarkHttpAsNonSecure);
72
73 if (choice == "no" || group == "no")
felt 2014/12/23 01:34:58 Doesn't this mean that as long as the Finch trial
palmer 2015/01/07 00:59:00 You're right, thanks. Changing it so that the user
74 return ToolbarModel::NONE;
75 else if (choice == "dubious" || group == "dubious")
76 return ToolbarModel::SECURITY_WARNING;
77 else if (choice == "non-secure" || group == "non-secure")
78 return ToolbarModel::SECURITY_ERROR;
79 return ToolbarModel::NONE;
80 }
81
68 } // namespace 82 } // namespace
69 83
70 ToolbarModelImpl::ToolbarModelImpl(ToolbarModelDelegate* delegate) 84 ToolbarModelImpl::ToolbarModelImpl(ToolbarModelDelegate* delegate)
71 : delegate_(delegate) { 85 : delegate_(delegate) {
72 } 86 }
73 87
74 ToolbarModelImpl::~ToolbarModelImpl() { 88 ToolbarModelImpl::~ToolbarModelImpl() {
75 } 89 }
76 90
77 // static 91 // static
78 ToolbarModel::SecurityLevel ToolbarModelImpl::GetSecurityLevelForWebContents( 92 ToolbarModel::SecurityLevel ToolbarModelImpl::GetSecurityLevelForWebContents(
79 content::WebContents* web_contents) { 93 content::WebContents* web_contents) {
80 if (!web_contents) 94 if (!web_contents)
81 return NONE; 95 return NONE;
82 96
83 NavigationEntry* entry = web_contents->GetController().GetVisibleEntry(); 97 NavigationEntry* entry = web_contents->GetController().GetVisibleEntry();
84 if (!entry) 98 if (!entry)
85 return NONE; 99 return NONE;
86 100
87 const SSLStatus& ssl = entry->GetSSL(); 101 const SSLStatus& ssl = entry->GetSSL();
88 switch (ssl.security_style) { 102 switch (ssl.security_style) {
89 case content::SECURITY_STYLE_UNKNOWN: 103 case content::SECURITY_STYLE_UNKNOWN:
90 case content::SECURITY_STYLE_UNAUTHENTICATED:
91 return NONE; 104 return NONE;
92 105
106 case content::SECURITY_STYLE_UNAUTHENTICATED: {
107 const GURL& url = entry->GetURL();
108 if (url.SchemeIs("http") || url.SchemeIs("ftp"))
109 return GetSecurityLevelForHttpFieldTrial();
110 return NONE;
111 }
112
93 case content::SECURITY_STYLE_AUTHENTICATION_BROKEN: 113 case content::SECURITY_STYLE_AUTHENTICATION_BROKEN:
94 return SECURITY_ERROR; 114 return SECURITY_ERROR;
95 115
96 case content::SECURITY_STYLE_AUTHENTICATED: { 116 case content::SECURITY_STYLE_AUTHENTICATED: {
97 #if defined(OS_CHROMEOS) 117 #if defined(OS_CHROMEOS)
98 policy::PolicyCertService* service = 118 policy::PolicyCertService* service =
99 policy::PolicyCertServiceFactory::GetForProfile( 119 policy::PolicyCertServiceFactory::GetForProfile(
100 Profile::FromBrowserContext(web_contents->GetBrowserContext())); 120 Profile::FromBrowserContext(web_contents->GetBrowserContext()));
101 if (service && service->UsedPolicyCertificates()) 121 if (service && service->UsedPolicyCertificates())
102 return SECURITY_POLICY_WARNING; 122 return SECURITY_POLICY_WARNING;
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 if (entry && 411 if (entry &&
392 google_util::StartsWithCommandLineGoogleBaseURL(entry->GetVirtualURL())) 412 google_util::StartsWithCommandLineGoogleBaseURL(entry->GetVirtualURL()))
393 return search_terms; 413 return search_terms;
394 414
395 // Otherwise, extract search terms for HTTPS pages that do not have a security 415 // Otherwise, extract search terms for HTTPS pages that do not have a security
396 // error. 416 // error.
397 ToolbarModel::SecurityLevel security_level = GetSecurityLevel(ignore_editing); 417 ToolbarModel::SecurityLevel security_level = GetSecurityLevel(ignore_editing);
398 return ((security_level == NONE) || (security_level == SECURITY_ERROR)) ? 418 return ((security_level == NONE) || (security_level == SECURITY_ERROR)) ?
399 base::string16() : search_terms; 419 base::string16() : search_terms;
400 } 420 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698