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

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: de-format, meet field trial style on the field of style trial 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 bool GetSecurityLevelForHttpFieldTrial(ToolbarModel::SecurityLevel* level) {
jww 2014/12/20 02:07:58 This certainly works, but instead of returning a b
palmer 2014/12/20 02:32:33 I modeled this after GetSecurityLevelForFieldTrial
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")
74 *level = ToolbarModel::NONE;
75 else if (choice == "dubious" || group == "dubious")
76 *level = ToolbarModel::SECURITY_WARNING;
77 else if (choice == "non-secure" || group == "non-secure")
78 *level = ToolbarModel::SECURITY_ERROR;
79 else
80 return false;
81 return true;
jww 2014/12/20 02:07:58 This is unreachable code.
palmer 2014/12/20 02:32:34 I'm not sure why?
82 }
83
68 } // namespace 84 } // namespace
69 85
70 ToolbarModelImpl::ToolbarModelImpl(ToolbarModelDelegate* delegate) 86 ToolbarModelImpl::ToolbarModelImpl(ToolbarModelDelegate* delegate)
71 : delegate_(delegate) { 87 : delegate_(delegate) {
72 } 88 }
73 89
74 ToolbarModelImpl::~ToolbarModelImpl() { 90 ToolbarModelImpl::~ToolbarModelImpl() {
75 } 91 }
76 92
77 // static 93 // static
78 ToolbarModel::SecurityLevel ToolbarModelImpl::GetSecurityLevelForWebContents( 94 ToolbarModel::SecurityLevel ToolbarModelImpl::GetSecurityLevelForWebContents(
79 content::WebContents* web_contents) { 95 content::WebContents* web_contents) {
80 if (!web_contents) 96 if (!web_contents)
81 return NONE; 97 return NONE;
82 98
83 NavigationEntry* entry = web_contents->GetController().GetVisibleEntry(); 99 NavigationEntry* entry = web_contents->GetController().GetVisibleEntry();
84 if (!entry) 100 if (!entry)
85 return NONE; 101 return NONE;
86 102
87 const SSLStatus& ssl = entry->GetSSL(); 103 const SSLStatus& ssl = entry->GetSSL();
88 switch (ssl.security_style) { 104 switch (ssl.security_style) {
89 case content::SECURITY_STYLE_UNKNOWN: 105 case content::SECURITY_STYLE_UNKNOWN:
90 case content::SECURITY_STYLE_UNAUTHENTICATED:
91 return NONE; 106 return NONE;
107 case content::SECURITY_STYLE_UNAUTHENTICATED: {
108 ToolbarModel::SecurityLevel security_level = NONE;
109 if (GetSecurityLevelForHttpFieldTrial(&security_level))
110 return security_level;
111 return NONE;
112 }
92 113
93 case content::SECURITY_STYLE_AUTHENTICATION_BROKEN: 114 case content::SECURITY_STYLE_AUTHENTICATION_BROKEN:
94 return SECURITY_ERROR; 115 return SECURITY_ERROR;
95 116
96 case content::SECURITY_STYLE_AUTHENTICATED: { 117 case content::SECURITY_STYLE_AUTHENTICATED: {
97 #if defined(OS_CHROMEOS) 118 #if defined(OS_CHROMEOS)
98 policy::PolicyCertService* service = 119 policy::PolicyCertService* service =
99 policy::PolicyCertServiceFactory::GetForProfile( 120 policy::PolicyCertServiceFactory::GetForProfile(
100 Profile::FromBrowserContext(web_contents->GetBrowserContext())); 121 Profile::FromBrowserContext(web_contents->GetBrowserContext()));
101 if (service && service->UsedPolicyCertificates()) 122 if (service && service->UsedPolicyCertificates())
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 if (entry && 412 if (entry &&
392 google_util::StartsWithCommandLineGoogleBaseURL(entry->GetVirtualURL())) 413 google_util::StartsWithCommandLineGoogleBaseURL(entry->GetVirtualURL()))
393 return search_terms; 414 return search_terms;
394 415
395 // Otherwise, extract search terms for HTTPS pages that do not have a security 416 // Otherwise, extract search terms for HTTPS pages that do not have a security
396 // error. 417 // error.
397 ToolbarModel::SecurityLevel security_level = GetSecurityLevel(ignore_editing); 418 ToolbarModel::SecurityLevel security_level = GetSecurityLevel(ignore_editing);
398 return ((security_level == NONE) || (security_level == SECURITY_ERROR)) ? 419 return ((security_level == NONE) || (security_level == SECURITY_ERROR)) ?
399 base::string16() : search_terms; 420 base::string16() : search_terms;
400 } 421 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698