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

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

Issue 14752005: Finch experiments on SSL, malware, and phishing interstitials (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: SHOW_ADVANCED Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/ssl/ssl_blocking_page.h" 5 #include "chrome/browser/ssl/ssl_blocking_page.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/metrics/field_trial.h"
8 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
9 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
10 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/renderer_preferences_util.h" 14 #include "chrome/browser/renderer_preferences_util.h"
14 #include "chrome/browser/ssl/ssl_error_info.h" 15 #include "chrome/browser/ssl/ssl_error_info.h"
15 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_finder.h" 17 #include "chrome/browser/ui/browser_finder.h"
17 #include "content/public/browser/cert_store.h" 18 #include "content/public/browser/cert_store.h"
18 #include "content/public/browser/interstitial_page.h" 19 #include "content/public/browser/interstitial_page.h"
19 #include "content/public/browser/navigation_controller.h" 20 #include "content/public/browser/navigation_controller.h"
20 #include "content/public/browser/navigation_entry.h" 21 #include "content/public/browser/navigation_entry.h"
21 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
22 #include "content/public/browser/notification_types.h" 23 #include "content/public/browser/notification_types.h"
23 #include "content/public/browser/render_process_host.h" 24 #include "content/public/browser/render_process_host.h"
24 #include "content/public/browser/render_view_host.h" 25 #include "content/public/browser/render_view_host.h"
25 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
26 #include "content/public/common/ssl_status.h" 27 #include "content/public/common/ssl_status.h"
28 #include "grit/app_locale_settings.h"
27 #include "grit/browser_resources.h" 29 #include "grit/browser_resources.h"
28 #include "grit/generated_resources.h" 30 #include "grit/generated_resources.h"
29 #include "net/base/net_errors.h" 31 #include "net/base/net_errors.h"
30 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
31 #include "ui/base/resource/resource_bundle.h" 33 #include "ui/base/resource/resource_bundle.h"
32 #include "ui/webui/jstemplate_builder.h" 34 #include "ui/webui/jstemplate_builder.h"
33 35
36 #if defined(OS_WIN)
37 #include "base/win/windows_version.h"
38 #endif
39
34 using base::TimeDelta; 40 using base::TimeDelta;
35 using base::TimeTicks; 41 using base::TimeTicks;
36 using content::InterstitialPage; 42 using content::InterstitialPage;
37 using content::NavigationController; 43 using content::NavigationController;
38 using content::NavigationEntry; 44 using content::NavigationEntry;
39 45
40 #define HISTOGRAM_INTERSTITIAL_SMALL_TIME(name, sample) \ 46 #define HISTOGRAM_INTERSTITIAL_SMALL_TIME(name, sample) \
41 UMA_HISTOGRAM_CUSTOM_TIMES( \ 47 UMA_HISTOGRAM_CUSTOM_TIMES( \
42 name, \ 48 name, \
43 sample, \ 49 sample, \
44 base::TimeDelta::FromMilliseconds(400), \ 50 base::TimeDelta::FromMilliseconds(400), \
45 base::TimeDelta::FromMinutes(15), 75); 51 base::TimeDelta::FromMinutes(15), 75);
46 52
47 #define HISTOGRAM_INTERSTITIAL_LARGE_TIME(name, sample) \ 53 #define HISTOGRAM_INTERSTITIAL_LARGE_TIME(name, sample) \
48 UMA_HISTOGRAM_CUSTOM_TIMES( \ 54 UMA_HISTOGRAM_CUSTOM_TIMES( \
49 name, \ 55 name, \
50 sample, \ 56 sample, \
51 base::TimeDelta::FromMilliseconds(400), \ 57 base::TimeDelta::FromMilliseconds(400), \
52 base::TimeDelta::FromMinutes(20), 50); 58 base::TimeDelta::FromMinutes(20), 50);
53 59
54 namespace { 60 namespace {
55 61
56 // These represent the commands sent by ssl_roadblock.html. 62 // These represent the commands sent by ssl_roadblock.html.
57 enum SSLBlockingPageCommands { 63 enum SSLBlockingPageCommands {
58 CMD_DONT_PROCEED, 64 CMD_DONT_PROCEED,
59 CMD_PROCEED, 65 CMD_PROCEED,
60 CMD_FOCUS, 66 CMD_FOCUS,
61 CMD_MORE, 67 CMD_MORE,
68 CMD_SHOW_UNDERSTAND, // Used by the Finch trial.
James Hawkins 2013/05/06 18:13:57 nit: Only two spaces before comment.
felt 2013/05/06 19:47:52 Done.
62 }; 69 };
63 70
64 // Events for UMA. 71 // Events for UMA.
65 enum SSLBlockingPageEvent { 72 enum SSLBlockingPageEvent {
66 SHOW_ALL, 73 SHOW_ALL,
67 SHOW_OVERRIDABLE, 74 SHOW_OVERRIDABLE,
68 PROCEED_OVERRIDABLE, 75 PROCEED_OVERRIDABLE,
69 PROCEED_NAME, 76 PROCEED_NAME,
70 PROCEED_DATE, 77 PROCEED_DATE,
71 PROCEED_AUTHORITY, 78 PROCEED_AUTHORITY,
72 DONT_PROCEED_OVERRIDABLE, 79 DONT_PROCEED_OVERRIDABLE,
73 DONT_PROCEED_NAME, 80 DONT_PROCEED_NAME,
74 DONT_PROCEED_DATE, 81 DONT_PROCEED_DATE,
75 DONT_PROCEED_AUTHORITY, 82 DONT_PROCEED_AUTHORITY,
76 MORE, 83 MORE,
84 SHOW_UNDERSTAND,
77 UNUSED_BLOCKING_PAGE_EVENT, 85 UNUSED_BLOCKING_PAGE_EVENT,
78 }; 86 };
79 87
80 void RecordSSLBlockingPageEventStats(SSLBlockingPageEvent event) { 88 void RecordSSLBlockingPageEventStats(SSLBlockingPageEvent event) {
81 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl", 89 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl",
82 event, 90 event,
83 UNUSED_BLOCKING_PAGE_EVENT); 91 UNUSED_BLOCKING_PAGE_EVENT);
84 } 92 }
85 93
86 void RecordSSLBlockingPageTimeStats( 94 void RecordSSLBlockingPageTimeStats(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 else 145 else
138 RecordSSLBlockingPageEventStats(DONT_PROCEED_AUTHORITY); 146 RecordSSLBlockingPageEventStats(DONT_PROCEED_AUTHORITY);
139 break; 147 break;
140 } 148 }
141 default: { 149 default: {
142 break; 150 break;
143 } 151 }
144 } 152 }
145 } 153 }
146 154
155 // These are the constants for the Finch experiment.
156 static const char kStudyName[] = "InterstitialSSL517";
James Hawkins 2013/05/06 18:13:57 nit: Remove static in unnamed namespace.
felt 2013/05/06 19:47:52 Done.
157 static const char kCondition15Control[] = "Condition15SSLControl";
158 static const char kCondition16Firefox[] = "Condition16SSLFirefox";
159 static const char kCondition17FancyFirefox[] = "Condition17SSLFancyFirefox";
160 static const char kCondition18NoImages[] = "Condition18SSLNoImages";
161
147 } // namespace 162 } // namespace
148 163
149 // Note that we always create a navigation entry with SSL errors. 164 // Note that we always create a navigation entry with SSL errors.
150 // No error happening loading a sub-resource triggers an interstitial so far. 165 // No error happening loading a sub-resource triggers an interstitial so far.
151 SSLBlockingPage::SSLBlockingPage( 166 SSLBlockingPage::SSLBlockingPage(
152 content::WebContents* web_contents, 167 content::WebContents* web_contents,
153 int cert_error, 168 int cert_error,
154 const net::SSLInfo& ssl_info, 169 const net::SSLInfo& ssl_info,
155 const GURL& request_url, 170 const GURL& request_url,
156 bool overridable, 171 bool overridable,
157 bool strict_enforcement, 172 bool strict_enforcement,
158 const base::Callback<void(bool)>& callback) 173 const base::Callback<void(bool)>& callback)
159 : callback_(callback), 174 : callback_(callback),
160 web_contents_(web_contents), 175 web_contents_(web_contents),
161 cert_error_(cert_error), 176 cert_error_(cert_error),
162 ssl_info_(ssl_info), 177 ssl_info_(ssl_info),
163 request_url_(request_url), 178 request_url_(request_url),
164 overridable_(overridable), 179 overridable_(overridable),
165 strict_enforcement_(strict_enforcement) { 180 strict_enforcement_(strict_enforcement) {
181 trialCondition_ = base::FieldTrialList::FindFullName(kStudyName);
182
166 RecordSSLBlockingPageEventStats(SHOW_ALL); 183 RecordSSLBlockingPageEventStats(SHOW_ALL);
167 if (overridable_ && !strict_enforcement_) 184 if (overridable_ && !strict_enforcement_)
168 RecordSSLBlockingPageEventStats(SHOW_OVERRIDABLE); 185 RecordSSLBlockingPageEventStats(SHOW_OVERRIDABLE);
169 186
170 interstitial_page_ = InterstitialPage::Create( 187 interstitial_page_ = InterstitialPage::Create(
171 web_contents_, true, request_url, this); 188 web_contents_, true, request_url, this);
172 display_start_time_ = TimeTicks(); 189 display_start_time_ = TimeTicks();
173 interstitial_page_->Show(); 190 interstitial_page_->Show();
174 } 191 }
175 192
176 SSLBlockingPage::~SSLBlockingPage() { 193 SSLBlockingPage::~SSLBlockingPage() {
177 if (!callback_.is_null()) { 194 if (!callback_.is_null()) {
195 RecordSSLBlockingPageTimeStats(
196 false, cert_error_,
197 overridable_ && !strict_enforcement_, display_start_time_,
198 base::TimeTicks::Now());
178 // The page is closed without the user having chosen what to do, default to 199 // The page is closed without the user having chosen what to do, default to
179 // deny. 200 // deny.
180 NotifyDenyCertificate(); 201 NotifyDenyCertificate();
181 } 202 }
182 } 203 }
183 204
184 std::string SSLBlockingPage::GetHTMLContents() { 205 std::string SSLBlockingPage::GetHTMLContents() {
185 // Let's build the html error page. 206 // Let's build the html error page.
186 DictionaryValue strings; 207 DictionaryValue strings;
187 SSLErrorInfo error_info = SSLErrorInfo::CreateError( 208 SSLErrorInfo error_info = SSLErrorInfo::CreateError(
188 SSLErrorInfo::NetErrorToErrorType(cert_error_), ssl_info_.cert, 209 SSLErrorInfo::NetErrorToErrorType(cert_error_), ssl_info_.cert,
189 request_url_); 210 request_url_);
190 211
212 int resource_id = IDR_SSL_ROAD_BLOCK_HTML;
191 strings.SetString("headLine", error_info.title()); 213 strings.SetString("headLine", error_info.title());
192 strings.SetString("description", error_info.details()); 214 strings.SetString("description", error_info.details());
193 strings.SetString("moreInfoTitle", 215 strings.SetString("moreInfoTitle",
194 l10n_util::GetStringUTF16(IDS_CERT_ERROR_EXTRA_INFO_TITLE)); 216 l10n_util::GetStringUTF16(IDS_CERT_ERROR_EXTRA_INFO_TITLE));
195 SetExtraInfo(&strings, error_info.extra_information()); 217 SetExtraInfo(&strings, error_info.extra_information());
196 218
197 strings.SetString("exit", 219 strings.SetString("exit",
198 l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_EXIT)); 220 l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_EXIT));
199 221
200 int resource_id = IDR_SSL_ROAD_BLOCK_HTML;
201 if (overridable_ && !strict_enforcement_) { 222 if (overridable_ && !strict_enforcement_) {
202 strings.SetString("title", 223 strings.SetString("title",
203 l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_TITLE)); 224 l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_TITLE));
204 strings.SetString("proceed", 225 strings.SetString("proceed",
205 l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_PROCEED)); 226 l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_PROCEED));
206 strings.SetString("reasonForNotProceeding", 227 strings.SetString("reasonForNotProceeding",
207 l10n_util::GetStringUTF16( 228 l10n_util::GetStringUTF16(
208 IDS_SSL_BLOCKING_PAGE_SHOULD_NOT_PROCEED)); 229 IDS_SSL_BLOCKING_PAGE_SHOULD_NOT_PROCEED));
209 // The value of errorType doesn't matter; we actually just check if it's 230 strings.SetString("errorType", "overridable");
210 // empty or not in ssl_roadblock.
211 strings.SetString("errorType",
212 l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_TITLE));
213 } else { 231 } else {
214 strings.SetString("title", 232 strings.SetString("title",
215 l10n_util::GetStringUTF16(IDS_SSL_ERROR_PAGE_TITLE)); 233 l10n_util::GetStringUTF16(IDS_SSL_ERROR_PAGE_TITLE));
216 if (strict_enforcement_) { 234 if (strict_enforcement_) {
217 strings.SetString("reasonForNotProceeding", 235 strings.SetString("reasonForNotProceeding",
218 l10n_util::GetStringUTF16( 236 l10n_util::GetStringUTF16(
219 IDS_SSL_ERROR_PAGE_CANNOT_PROCEED)); 237 IDS_SSL_ERROR_PAGE_CANNOT_PROCEED));
220 } else { 238 } else {
221 strings.SetString("reasonForNotProceeding", std::string()); 239 strings.SetString("reasonForNotProceeding", std::string());
222 } 240 }
223 strings.SetString("errorType", std::string()); 241 strings.SetString("errorType", "notoverridable");
224 } 242 }
225 243
226 strings.SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr"); 244 strings.SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr");
227 245
246 // Set up the Finch trial layouts.
247 strings.SetString("trialType", trialCondition_);
248 if (trialCondition_ == kCondition16Firefox ||
249 trialCondition_ == kCondition17FancyFirefox ||
250 trialCondition_ == kCondition18NoImages) {
251 strings.SetString("domain", request_url_.host());
252 std::string font_family = l10n_util::GetStringUTF8(IDS_WEB_FONT_FAMILY);
253 #if defined(OS_WIN)
254 if (base::win::GetVersion() < base::win::VERSION_VISTA) {
255 font_family = l10n_util::GetStringUTF8(IDS_WEB_FONT_FAMILY_XP);
256 }
257 #endif
258 #if defined(TOOLKIT_GTK)
259 font_family = ui::ResourceBundle::GetSharedInstance().GetFont(
260 ui::ResourceBundle::BaseFont).GetFontName() + ", " + font_family;
261 #endif
262 strings.SetString("fontfamily", font_family);
263 if (trialCondition_ == kCondition16Firefox ||
264 trialCondition_ == kCondition18NoImages) {
265 resource_id = IDR_SSL_FIREFOX_HTML;
266 } else if (trialCondition_ == kCondition17FancyFirefox) {
267 resource_id = IDR_SSL_FANCY_FIREFOX_HTML;
268 }
269 }
270
228 base::StringPiece html( 271 base::StringPiece html(
229 ResourceBundle::GetSharedInstance().GetRawDataResource( 272 ResourceBundle::GetSharedInstance().GetRawDataResource(
230 resource_id)); 273 resource_id));
231 274
232 return webui::GetI18nTemplateHtml(html, &strings); 275 return webui::GetI18nTemplateHtml(html, &strings);
233 } 276 }
234 277
235 void SSLBlockingPage::OverrideEntry(NavigationEntry* entry) { 278 void SSLBlockingPage::OverrideEntry(NavigationEntry* entry) {
236 int cert_id = content::CertStore::GetInstance()->StoreCert( 279 int cert_id = content::CertStore::GetInstance()->StoreCert(
237 ssl_info_.cert, web_contents_->GetRenderProcessHost()->GetID()); 280 ssl_info_.cert, web_contents_->GetRenderProcessHost()->GetID());
(...skipping 15 matching lines...) Expand all
253 int cmd = atoi(command.c_str()); 296 int cmd = atoi(command.c_str());
254 if (cmd == CMD_DONT_PROCEED) { 297 if (cmd == CMD_DONT_PROCEED) {
255 interstitial_page_->DontProceed(); 298 interstitial_page_->DontProceed();
256 } else if (cmd == CMD_PROCEED) { 299 } else if (cmd == CMD_PROCEED) {
257 interstitial_page_->Proceed(); 300 interstitial_page_->Proceed();
258 } else if (cmd == CMD_FOCUS) { 301 } else if (cmd == CMD_FOCUS) {
259 // Start recording the time when the page is first in focus 302 // Start recording the time when the page is first in focus
260 display_start_time_ = base::TimeTicks::Now(); 303 display_start_time_ = base::TimeTicks::Now();
261 } else if (cmd == CMD_MORE) { 304 } else if (cmd == CMD_MORE) {
262 RecordSSLBlockingPageEventStats(MORE); 305 RecordSSLBlockingPageEventStats(MORE);
306 } else if (cmd == CMD_SHOW_UNDERSTAND) {
307 // Used in the Finch experiment.
308 RecordSSLBlockingPageEventStats(SHOW_UNDERSTAND);
263 } 309 }
264 } 310 }
265 311
266 void SSLBlockingPage::OverrideRendererPrefs( 312 void SSLBlockingPage::OverrideRendererPrefs(
267 content::RendererPreferences* prefs) { 313 content::RendererPreferences* prefs) {
268 Profile* profile = Profile::FromBrowserContext( 314 Profile* profile = Profile::FromBrowserContext(
269 web_contents_->GetBrowserContext()); 315 web_contents_->GetBrowserContext());
270 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile); 316 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile);
271 } 317 }
272 318
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 "moreInfo1", "moreInfo2", "moreInfo3", "moreInfo4", "moreInfo5" 360 "moreInfo1", "moreInfo2", "moreInfo3", "moreInfo4", "moreInfo5"
315 }; 361 };
316 int i; 362 int i;
317 for (i = 0; i < static_cast<int>(extra_info.size()); i++) { 363 for (i = 0; i < static_cast<int>(extra_info.size()); i++) {
318 strings->SetString(keys[i], extra_info[i]); 364 strings->SetString(keys[i], extra_info[i]);
319 } 365 }
320 for (; i < 5; i++) { 366 for (; i < 5; i++) {
321 strings->SetString(keys[i], std::string()); 367 strings->SetString(keys[i], std::string());
322 } 368 }
323 } 369 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698