OLD | NEW |
---|---|
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 // Implementation of the SafeBrowsingBlockingPage class. | 5 // Implementation of the SafeBrowsingBlockingPage class. |
6 | 6 |
7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" | 7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 // Constants for the Experience Sampling instrumentation. | 110 // Constants for the Experience Sampling instrumentation. |
111 #if defined(ENABLE_EXTENSIONS) | 111 #if defined(ENABLE_EXTENSIONS) |
112 const char kEventNameMalware[] = "safebrowsing_interstitial_"; | 112 const char kEventNameMalware[] = "safebrowsing_interstitial_"; |
113 const char kEventNamePhishing[] = "phishing_interstitial_"; | 113 const char kEventNamePhishing[] = "phishing_interstitial_"; |
114 const char kEventNameOther[] = "safebrowsing_other_interstitial_"; | 114 const char kEventNameOther[] = "safebrowsing_other_interstitial_"; |
115 #endif | 115 #endif |
116 | 116 |
117 base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap> | 117 base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap> |
118 g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER; | 118 g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER; |
119 | 119 |
120 // This enum is used for a histogram. Don't reorder, delete, or insert | |
121 // elements. New elements should be added before MAX_ACTION only. | |
122 enum DetailedDecision { | |
123 MALWARE_SHOW_NEW_SITE = 0, | |
124 MALWARE_PROCEED_NEW_SITE, | |
125 MALWARE_SHOW_CROSS_SITE, | |
126 MALWARE_PROCEED_CROSS_SITE, | |
127 PHISHING_SHOW_NEW_SITE, | |
128 PHISHING_PROCEED_NEW_SITE, | |
129 PHISHING_SHOW_CROSS_SITE, | |
130 PHISHING_PROCEED_CROSS_SITE, | |
131 MAX_DETAILED_ACTION | |
132 }; | |
133 | |
134 void RecordDetailedUserAction(DetailedDecision decision) { | |
135 UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialActionDetails", | |
136 decision, | |
137 MAX_DETAILED_ACTION); | |
138 } | |
139 | |
140 } // namespace | 120 } // namespace |
141 | 121 |
142 // static | 122 // static |
143 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; | 123 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; |
144 | 124 |
145 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we | 125 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we |
146 // don't leak it. | 126 // don't leak it. |
147 class SafeBrowsingBlockingPageFactoryImpl | 127 class SafeBrowsingBlockingPageFactoryImpl |
148 : public SafeBrowsingBlockingPageFactory { | 128 : public SafeBrowsingBlockingPageFactory { |
149 public: | 129 public: |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL); | 179 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL); |
200 phishing = true; | 180 phishing = true; |
201 } | 181 } |
202 } | 182 } |
203 DCHECK(phishing || malware); | 183 DCHECK(phishing || malware); |
204 if (malware) | 184 if (malware) |
205 interstitial_type_ = TYPE_MALWARE; | 185 interstitial_type_ = TYPE_MALWARE; |
206 else | 186 else |
207 interstitial_type_ = TYPE_PHISHING; | 187 interstitial_type_ = TYPE_PHISHING; |
208 | 188 |
209 RecordUserAction(SHOW); | 189 RecordUserDecision(SHOW); |
190 RecordUserInteraction(TOTAL_VISITS); | |
191 if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) | |
192 RecordUserDecision(PROCEEDING_DISABLED); | |
193 | |
210 HistoryService* history_service = HistoryServiceFactory::GetForProfile( | 194 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
211 Profile::FromBrowserContext(web_contents->GetBrowserContext()), | 195 Profile::FromBrowserContext(web_contents->GetBrowserContext()), |
212 Profile::EXPLICIT_ACCESS); | 196 Profile::EXPLICIT_ACCESS); |
213 if (history_service) { | 197 if (history_service) { |
214 history_service->GetVisibleVisitCountToHost( | 198 history_service->GetVisibleVisitCountToHost( |
215 url_, | 199 url_, |
216 base::Bind(&SafeBrowsingBlockingPage::OnGotHistoryCount, | 200 base::Bind(&SafeBrowsingBlockingPage::OnGotHistoryCount, |
217 base::Unretained(this)), | 201 base::Unretained(this)), |
218 &request_tracker_); | 202 &request_tracker_); |
219 } | 203 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 return; | 267 return; |
284 } | 268 } |
285 | 269 |
286 if (command == kDontReportCommand) { | 270 if (command == kDontReportCommand) { |
287 SetReportingPreference(false); | 271 SetReportingPreference(false); |
288 return; | 272 return; |
289 } | 273 } |
290 | 274 |
291 if (command == kLearnMoreCommand) { | 275 if (command == kLearnMoreCommand) { |
292 // User pressed "Learn more". | 276 // User pressed "Learn more". |
293 #if defined(ENABLE_EXTENSIONS) | 277 RecordUserInteraction(SHOW_LEARN_MORE); |
294 if (sampling_event_.get()) | |
295 sampling_event_->set_has_viewed_learn_more(true); | |
296 #endif | |
297 GURL learn_more_url(interstitial_type_ == TYPE_PHISHING ? | 278 GURL learn_more_url(interstitial_type_ == TYPE_PHISHING ? |
298 kLearnMorePhishingUrlV2 : kLearnMoreMalwareUrlV2); | 279 kLearnMorePhishingUrlV2 : kLearnMoreMalwareUrlV2); |
299 learn_more_url = google_util::AppendGoogleLocaleParam( | 280 learn_more_url = google_util::AppendGoogleLocaleParam( |
300 learn_more_url, g_browser_process->GetApplicationLocale()); | 281 learn_more_url, g_browser_process->GetApplicationLocale()); |
301 OpenURLParams params(learn_more_url, | 282 OpenURLParams params(learn_more_url, |
302 Referrer(), | 283 Referrer(), |
303 CURRENT_TAB, | 284 CURRENT_TAB, |
304 content::PAGE_TRANSITION_LINK, | 285 content::PAGE_TRANSITION_LINK, |
305 false); | 286 false); |
306 web_contents_->OpenURL(params); | 287 web_contents_->OpenURL(params); |
307 return; | 288 return; |
308 } | 289 } |
309 | 290 |
310 if (command == kShowPrivacyCommand) { | 291 if (command == kShowPrivacyCommand) { |
311 // User pressed "Safe Browsing privacy policy". | 292 // User pressed "Safe Browsing privacy policy". |
293 RecordUserInteraction(SHOW_PRIVACY_POLICY); | |
312 GURL privacy_url( | 294 GURL privacy_url( |
313 l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_URL)); | 295 l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_URL)); |
314 privacy_url = google_util::AppendGoogleLocaleParam( | 296 privacy_url = google_util::AppendGoogleLocaleParam( |
315 privacy_url, g_browser_process->GetApplicationLocale()); | 297 privacy_url, g_browser_process->GetApplicationLocale()); |
316 OpenURLParams params(privacy_url, | 298 OpenURLParams params(privacy_url, |
317 Referrer(), | 299 Referrer(), |
318 CURRENT_TAB, | 300 CURRENT_TAB, |
319 content::PAGE_TRANSITION_LINK, | 301 content::PAGE_TRANSITION_LINK, |
320 false); | 302 false); |
321 web_contents_->OpenURL(params); | 303 web_contents_->OpenURL(params); |
322 return; | 304 return; |
323 } | 305 } |
324 | 306 |
325 bool proceed_blocked = false; | 307 bool proceed_blocked = false; |
326 if (command == kProceedCommand) { | 308 if (command == kProceedCommand) { |
327 if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) { | 309 if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) { |
328 proceed_blocked = true; | 310 proceed_blocked = true; |
329 } else { | 311 } else { |
312 RecordUserDecision(PROCEED); | |
330 interstitial_page_->Proceed(); | 313 interstitial_page_->Proceed(); |
331 // |this| has been deleted after Proceed() returns. | 314 // |this| has been deleted after Proceed() returns. |
332 return; | 315 return; |
333 } | 316 } |
334 } | 317 } |
335 | 318 |
336 if (command == kTakeMeBackCommand || proceed_blocked) { | 319 if (command == kTakeMeBackCommand || proceed_blocked) { |
320 // Don't record the user action here because there are other ways of | |
321 // triggering DontProceed, like clicking the back button. | |
337 if (is_main_frame_load_blocked_) { | 322 if (is_main_frame_load_blocked_) { |
338 // If the load is blocked, we want to close the interstitial and discard | 323 // If the load is blocked, we want to close the interstitial and discard |
339 // the pending entry. | 324 // the pending entry. |
340 interstitial_page_->DontProceed(); | 325 interstitial_page_->DontProceed(); |
341 // |this| has been deleted after DontProceed() returns. | 326 // |this| has been deleted after DontProceed() returns. |
342 return; | 327 return; |
343 } | 328 } |
344 | 329 |
345 // Otherwise the offending entry has committed, and we need to go back or | 330 // Otherwise the offending entry has committed, and we need to go back or |
346 // to a safe page. We will close the interstitial when that page commits. | 331 // to a safe page. We will close the interstitial when that page commits. |
(...skipping 26 matching lines...) Expand all Loading... | |
373 } | 358 } |
374 | 359 |
375 if (element_index >= unsafe_resources_.size()) { | 360 if (element_index >= unsafe_resources_.size()) { |
376 NOTREACHED(); | 361 NOTREACHED(); |
377 return; | 362 return; |
378 } | 363 } |
379 | 364 |
380 std::string bad_url_spec = unsafe_resources_[element_index].url.spec(); | 365 std::string bad_url_spec = unsafe_resources_[element_index].url.spec(); |
381 if (command == kShowDiagnosticCommand) { | 366 if (command == kShowDiagnosticCommand) { |
382 // We're going to take the user to Google's SafeBrowsing diagnostic page. | 367 // We're going to take the user to Google's SafeBrowsing diagnostic page. |
368 RecordUserInteraction(SHOW_DIAGNOSTIC); | |
383 std::string diagnostic = | 369 std::string diagnostic = |
384 base::StringPrintf(kSbDiagnosticUrl, | 370 base::StringPrintf(kSbDiagnosticUrl, |
385 net::EscapeQueryParamValue(bad_url_spec, true).c_str()); | 371 net::EscapeQueryParamValue(bad_url_spec, true).c_str()); |
386 GURL diagnostic_url(diagnostic); | 372 GURL diagnostic_url(diagnostic); |
387 diagnostic_url = google_util::AppendGoogleLocaleParam( | 373 diagnostic_url = google_util::AppendGoogleLocaleParam( |
388 diagnostic_url, g_browser_process->GetApplicationLocale()); | 374 diagnostic_url, g_browser_process->GetApplicationLocale()); |
389 DCHECK(unsafe_resources_[element_index].threat_type == | 375 DCHECK(unsafe_resources_[element_index].threat_type == |
390 SB_THREAT_TYPE_URL_MALWARE || | 376 SB_THREAT_TYPE_URL_MALWARE || |
391 unsafe_resources_[element_index].threat_type == | 377 unsafe_resources_[element_index].threat_type == |
392 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL); | 378 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL); |
393 OpenURLParams params( | 379 OpenURLParams params( |
394 diagnostic_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, | 380 diagnostic_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, |
395 false); | 381 false); |
396 web_contents_->OpenURL(params); | 382 web_contents_->OpenURL(params); |
397 return; | 383 return; |
398 } | 384 } |
399 | 385 |
400 if (command == kExpandedSeeMoreCommand) { | 386 if (command == kExpandedSeeMoreCommand) { |
401 // User expanded the "see more info" section of the page. We don't actually | 387 RecordUserInteraction(SHOW_ADVANCED); |
402 // do any action based on this, it's just so that RecordUserReactionTime can | |
403 // track it. | |
404 | |
405 #if defined(ENABLE_EXTENSIONS) | |
406 // ExperienceSampling: We track that the user expanded the details. | |
407 if (sampling_event_.get()) | |
408 sampling_event_->set_has_viewed_details(true); | |
409 #endif | |
410 return; | 388 return; |
411 } | 389 } |
412 | 390 |
413 NOTREACHED() << "Unexpected command: " << command; | 391 NOTREACHED() << "Unexpected command: " << command; |
414 } | 392 } |
415 | 393 |
416 void SafeBrowsingBlockingPage::OverrideRendererPrefs( | 394 void SafeBrowsingBlockingPage::OverrideRendererPrefs( |
417 content::RendererPreferences* prefs) { | 395 content::RendererPreferences* prefs) { |
418 Profile* profile = Profile::FromBrowserContext( | 396 Profile* profile = Profile::FromBrowserContext( |
419 web_contents_->GetBrowserContext()); | 397 web_contents_->GetBrowserContext()); |
420 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile); | 398 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile); |
421 } | 399 } |
422 | 400 |
423 void SafeBrowsingBlockingPage::SetReportingPreference(bool report) { | 401 void SafeBrowsingBlockingPage::SetReportingPreference(bool report) { |
424 Profile* profile = Profile::FromBrowserContext( | 402 Profile* profile = Profile::FromBrowserContext( |
425 web_contents_->GetBrowserContext()); | 403 web_contents_->GetBrowserContext()); |
426 PrefService* pref = profile->GetPrefs(); | 404 PrefService* pref = profile->GetPrefs(); |
427 pref->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, report); | 405 pref->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, report); |
428 UMA_HISTOGRAM_BOOLEAN("SB2.SetExtendedReportingEnabled", report); | 406 UMA_HISTOGRAM_BOOLEAN("SB2.SetExtendedReportingEnabled", report); |
429 } | 407 } |
430 | 408 |
431 void SafeBrowsingBlockingPage::OnProceed() { | 409 void SafeBrowsingBlockingPage::OnProceed() { |
432 proceeded_ = true; | 410 proceeded_ = true; |
433 RecordUserAction(PROCEED); | |
434 // Send the malware details, if we opted to. | 411 // Send the malware details, if we opted to. |
435 FinishMalwareDetails(malware_details_proceed_delay_ms_); | 412 FinishMalwareDetails(malware_details_proceed_delay_ms_); |
436 | 413 |
437 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, true); | 414 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, true); |
438 | 415 |
439 // Check to see if some new notifications of unsafe resources have been | 416 // Check to see if some new notifications of unsafe resources have been |
440 // received while we were showing the interstitial. | 417 // received while we were showing the interstitial. |
441 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); | 418 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); |
442 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents_); | 419 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents_); |
443 SafeBrowsingBlockingPage* blocking_page = NULL; | 420 SafeBrowsingBlockingPage* blocking_page = NULL; |
444 if (iter != unsafe_resource_map->end() && !iter->second.empty()) { | 421 if (iter != unsafe_resource_map->end() && !iter->second.empty()) { |
445 // Build an interstitial for all the unsafe resources notifications. | 422 // Build an interstitial for all the unsafe resources notifications. |
446 // Don't show it now as showing an interstitial while an interstitial is | 423 // Don't show it now as showing an interstitial while an interstitial is |
447 // already showing would cause DontProceed() to be invoked. | 424 // already showing would cause DontProceed() to be invoked. |
448 blocking_page = factory_->CreateSafeBrowsingPage(ui_manager_, web_contents_, | 425 blocking_page = factory_->CreateSafeBrowsingPage(ui_manager_, web_contents_, |
449 iter->second); | 426 iter->second); |
450 unsafe_resource_map->erase(iter); | 427 unsafe_resource_map->erase(iter); |
451 } | 428 } |
452 | 429 |
453 #if defined(ENABLE_EXTENSIONS) | |
454 // ExperienceSampling: Notify that user decided to proceed. | |
455 if (sampling_event_.get()) | |
456 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kProceed); | |
457 #endif | |
458 | |
459 // Now that this interstitial is gone, we can show the new one. | 430 // Now that this interstitial is gone, we can show the new one. |
460 if (blocking_page) | 431 if (blocking_page) |
461 blocking_page->Show(); | 432 blocking_page->Show(); |
462 } | 433 } |
463 | 434 |
464 void SafeBrowsingBlockingPage::DontCreateViewForTesting() { | 435 void SafeBrowsingBlockingPage::DontCreateViewForTesting() { |
465 create_view_ = false; | 436 create_view_ = false; |
466 } | 437 } |
467 | 438 |
468 void SafeBrowsingBlockingPage::Show() { | 439 void SafeBrowsingBlockingPage::Show() { |
469 DCHECK(!interstitial_page_); | 440 DCHECK(!interstitial_page_); |
470 interstitial_page_ = InterstitialPage::Create( | 441 interstitial_page_ = InterstitialPage::Create( |
471 web_contents_, is_main_frame_load_blocked_, url_, this); | 442 web_contents_, is_main_frame_load_blocked_, url_, this); |
472 if (!create_view_) | 443 if (!create_view_) |
473 interstitial_page_->DontCreateViewForTesting(); | 444 interstitial_page_->DontCreateViewForTesting(); |
474 interstitial_page_->Show(); | 445 interstitial_page_->Show(); |
475 } | 446 } |
476 | 447 |
477 void SafeBrowsingBlockingPage::OnDontProceed() { | 448 void SafeBrowsingBlockingPage::OnDontProceed() { |
478 // Calling this method twice will not double-count. | 449 // Calling this method twice will not double-count. |
479 RecordUserReactionTime(kNavigatedAwayMetaCommand); | 450 RecordUserReactionTime(kNavigatedAwayMetaCommand); |
480 // We could have already called Proceed(), in which case we must not notify | 451 // We could have already called Proceed(), in which case we must not notify |
481 // the SafeBrowsingUIManager again, as the client has been deleted. | 452 // the SafeBrowsingUIManager again, as the client has been deleted. |
482 if (proceeded_) | 453 if (proceeded_) |
483 return; | 454 return; |
484 | 455 |
485 RecordUserAction(DONT_PROCEED); | 456 if (!IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) |
457 RecordUserDecision(DONT_PROCEED); | |
458 | |
486 // Send the malware details, if we opted to. | 459 // Send the malware details, if we opted to. |
487 FinishMalwareDetails(0); // No delay | 460 FinishMalwareDetails(0); // No delay |
488 | 461 |
489 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, false); | 462 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, false); |
490 | 463 |
491 // The user does not want to proceed, clear the queued unsafe resources | 464 // The user does not want to proceed, clear the queued unsafe resources |
492 // notifications we received while the interstitial was showing. | 465 // notifications we received while the interstitial was showing. |
493 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); | 466 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); |
494 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents_); | 467 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents_); |
495 if (iter != unsafe_resource_map->end() && !iter->second.empty()) { | 468 if (iter != unsafe_resource_map->end() && !iter->second.empty()) { |
496 NotifySafeBrowsingUIManager(ui_manager_, iter->second, false); | 469 NotifySafeBrowsingUIManager(ui_manager_, iter->second, false); |
497 unsafe_resource_map->erase(iter); | 470 unsafe_resource_map->erase(iter); |
498 } | 471 } |
499 | 472 |
500 // We don't remove the navigation entry if the tab is being destroyed as this | 473 // We don't remove the navigation entry if the tab is being destroyed as this |
501 // would trigger a navigation that would cause trouble as the render view host | 474 // would trigger a navigation that would cause trouble as the render view host |
502 // for the tab has by then already been destroyed. We also don't delete the | 475 // for the tab has by then already been destroyed. We also don't delete the |
503 // current entry if it has been committed again, which is possible on a page | 476 // current entry if it has been committed again, which is possible on a page |
504 // that had a subresource warning. | 477 // that had a subresource warning. |
505 int last_committed_index = | 478 int last_committed_index = |
506 web_contents_->GetController().GetLastCommittedEntryIndex(); | 479 web_contents_->GetController().GetLastCommittedEntryIndex(); |
507 if (navigation_entry_index_to_remove_ != -1 && | 480 if (navigation_entry_index_to_remove_ != -1 && |
508 navigation_entry_index_to_remove_ != last_committed_index && | 481 navigation_entry_index_to_remove_ != last_committed_index && |
509 !web_contents_->IsBeingDestroyed()) { | 482 !web_contents_->IsBeingDestroyed()) { |
510 CHECK(web_contents_->GetController().RemoveEntryAtIndex( | 483 CHECK(web_contents_->GetController().RemoveEntryAtIndex( |
511 navigation_entry_index_to_remove_)); | 484 navigation_entry_index_to_remove_)); |
512 navigation_entry_index_to_remove_ = -1; | 485 navigation_entry_index_to_remove_ = -1; |
513 } | 486 } |
514 | |
515 #if defined(ENABLE_EXTENSIONS) | |
516 // ExperienceSampling: Notify that user decided to go back. | |
517 // This also occurs if the user navigates away or closes the tab. | |
518 if (sampling_event_.get()) | |
519 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kDeny); | |
520 #endif | |
521 } | 487 } |
522 | 488 |
523 void SafeBrowsingBlockingPage::OnGotHistoryCount(bool success, | 489 void SafeBrowsingBlockingPage::OnGotHistoryCount(bool success, |
524 int num_visits, | 490 int num_visits, |
525 base::Time first_visit) { | 491 base::Time first_visit) { |
526 if (success) | 492 if (success) |
527 num_visits_ = num_visits; | 493 num_visits_ = num_visits; |
528 } | 494 } |
529 | 495 |
530 void SafeBrowsingBlockingPage::RecordUserAction(BlockingPageEvent event) { | 496 void SafeBrowsingBlockingPage::RecordUserDecision(Decision decision) { |
531 // This enum is used for a histogram. Don't reorder, delete, or insert | 497 switch (interstitial_type_) { |
532 // elements. New elements should be added before MAX_ACTION only. | 498 case TYPE_MALWARE: |
533 enum { | 499 UMA_HISTOGRAM_ENUMERATION("interstitial.malware.decision", |
534 MALWARE_SHOW = 0, | 500 decision, |
535 MALWARE_DONT_PROCEED, | 501 MAX_DECISION); |
536 MALWARE_FORCED_DONT_PROCEED, | |
537 MALWARE_PROCEED, | |
538 MULTIPLE_SHOW, | |
539 MULTIPLE_DONT_PROCEED, | |
540 MULTIPLE_FORCED_DONT_PROCEED, | |
541 MULTIPLE_PROCEED, | |
542 PHISHING_SHOW, | |
543 PHISHING_DONT_PROCEED, | |
544 PHISHING_FORCED_DONT_PROCEED, | |
545 PHISHING_PROCEED, | |
546 MALWARE_SHOW_ADVANCED, | |
547 MULTIPLE_SHOW_ADVANCED, | |
548 PHISHING_SHOW_ADVANCED, | |
549 MAX_ACTION | |
550 } histogram_action = MAX_ACTION; | |
551 | |
552 switch (event) { | |
553 case SHOW: | |
554 switch (interstitial_type_) { | |
555 case TYPE_MALWARE: | |
556 histogram_action = MALWARE_SHOW; | |
557 break; | |
558 case TYPE_PHISHING: | |
559 histogram_action = PHISHING_SHOW; | |
560 break; | |
561 } | |
562 break; | 502 break; |
563 case PROCEED: | 503 case TYPE_PHISHING: |
564 switch (interstitial_type_) { | 504 UMA_HISTOGRAM_ENUMERATION("interstitial.phishing.decision", |
565 case TYPE_MALWARE: | 505 decision, |
566 histogram_action = MALWARE_PROCEED; | 506 MAX_DECISION); |
567 break; | |
568 case TYPE_PHISHING: | |
569 histogram_action = PHISHING_PROCEED; | |
570 break; | |
571 } | |
572 break; | |
573 case DONT_PROCEED: | |
574 if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) { | |
575 switch (interstitial_type_) { | |
576 case TYPE_MALWARE: | |
577 histogram_action = MALWARE_FORCED_DONT_PROCEED; | |
578 break; | |
579 case TYPE_PHISHING: | |
580 histogram_action = PHISHING_FORCED_DONT_PROCEED; | |
581 break; | |
582 } | |
583 } else { | |
584 switch (interstitial_type_) { | |
585 case TYPE_MALWARE: | |
586 histogram_action = MALWARE_DONT_PROCEED; | |
587 break; | |
588 case TYPE_PHISHING: | |
589 histogram_action = PHISHING_DONT_PROCEED; | |
590 break; | |
591 } | |
592 } | |
593 break; | |
594 case SHOW_ADVANCED: | |
595 switch (interstitial_type_) { | |
596 case TYPE_MALWARE: | |
597 histogram_action = MALWARE_SHOW_ADVANCED; | |
598 break; | |
599 case TYPE_PHISHING: | |
600 histogram_action = PHISHING_SHOW_ADVANCED; | |
601 break; | |
602 } | |
603 break; | 507 break; |
604 default: | 508 default: |
605 NOTREACHED() << "Unexpected event: " << event; | 509 NOTREACHED(); |
606 } | |
607 if (histogram_action == MAX_ACTION) { | |
608 NOTREACHED(); | |
609 } else { | |
610 UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialAction", histogram_action, | |
611 MAX_ACTION); | |
612 } | 510 } |
613 | 511 |
614 if (event == PROCEED || event == DONT_PROCEED) { | 512 #if defined(ENABLE_EXTENSIONS) |
615 if (num_visits_ == 0) { | 513 if (sampling_event_.get()) { |
616 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? | 514 switch (decision) { |
617 MALWARE_SHOW_NEW_SITE : PHISHING_SHOW_NEW_SITE); | 515 case PROCEED: |
618 if (event == PROCEED) { | 516 sampling_event_->CreateUserDecisionEvent( |
619 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? | 517 ExperienceSamplingEvent::kProceed); |
620 MALWARE_PROCEED_NEW_SITE : PHISHING_PROCEED_NEW_SITE); | 518 break; |
621 } | 519 case DONT_PROCEED: |
520 sampling_event_->CreateUserDecisionEvent( | |
521 ExperienceSamplingEvent::kDeny); | |
522 break; | |
523 case SHOW: | |
524 case PROCEEDING_DISABLED: | |
525 case MAX_DECISION: | |
526 break; | |
622 } | 527 } |
623 if (unsafe_resources_[0].is_subresource) { | 528 } |
624 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? | 529 #endif |
625 MALWARE_SHOW_CROSS_SITE : PHISHING_SHOW_CROSS_SITE); | 530 |
626 if (event == PROCEED) { | 531 // Record additional information about malware sites that users have |
627 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? | 532 // visited before. |
628 MALWARE_PROCEED_CROSS_SITE : PHISHING_PROCEED_CROSS_SITE); | 533 if (num_visits_ < 1 || interstitial_type_ != TYPE_MALWARE) |
629 } | 534 return; |
630 } | 535 if (decision == PROCEED || decision == DONT_PROCEED) { |
536 UMA_HISTOGRAM_ENUMERATION("interstitial.malware.decision.repeat_visit", | |
537 SHOW, | |
538 MAX_DECISION); | |
539 UMA_HISTOGRAM_ENUMERATION("interstitial.malware.decision.repeat_visit", | |
540 decision, | |
541 MAX_DECISION); | |
631 } | 542 } |
632 } | 543 } |
633 | 544 |
545 void SafeBrowsingBlockingPage::RecordUserInteraction(Interaction interaction) { | |
546 switch (interstitial_type_) { | |
547 case TYPE_MALWARE: | |
548 UMA_HISTOGRAM_ENUMERATION("interstitial.malware.interaction", | |
549 interaction, | |
550 MAX_INTERACTION); | |
551 break; | |
552 case TYPE_PHISHING: | |
553 UMA_HISTOGRAM_ENUMERATION("interstitial.phishing.interaction", | |
554 interaction, | |
555 MAX_INTERACTION); | |
556 break; | |
557 default: | |
558 NOTREACHED(); | |
559 } | |
560 | |
561 #if defined(ENABLE_EXTENSIONS) | |
562 if (!sampling_event_.get()) | |
563 return; | |
564 switch (interaction) { | |
mattm
2014/09/17 01:22:21
Do you need TOTAL_VISITS in this switch?
felt
2014/09/17 01:27:12
Done.
| |
565 case SHOW_LEARN_MORE: | |
566 sampling_event_->set_has_viewed_learn_more(true); | |
567 break; | |
568 case SHOW_ADVANCED: | |
569 sampling_event_->set_has_viewed_details(true); | |
570 break; | |
571 case SHOW_PRIVACY_POLICY: | |
572 case SHOW_DIAGNOSTIC: | |
573 case MAX_INTERACTION: | |
574 break; | |
575 } | |
576 #endif | |
577 } | |
578 | |
634 void SafeBrowsingBlockingPage::RecordUserReactionTime( | 579 void SafeBrowsingBlockingPage::RecordUserReactionTime( |
635 const std::string& command) { | 580 const std::string& command) { |
636 if (interstitial_show_time_.is_null()) | 581 if (interstitial_show_time_.is_null()) |
637 return; // We already reported the user reaction time. | 582 return; // We already reported the user reaction time. |
638 base::TimeDelta dt = base::TimeTicks::Now() - interstitial_show_time_; | 583 base::TimeDelta dt = base::TimeTicks::Now() - interstitial_show_time_; |
639 DVLOG(1) << "User reaction time for command:" << command | 584 DVLOG(1) << "User reaction time for command:" << command |
640 << " on interstitial_type_:" << interstitial_type_ | 585 << " on interstitial_type_:" << interstitial_type_ |
641 << " warning took " << dt.InMilliseconds() << "ms"; | 586 << " warning took " << dt.InMilliseconds() << "ms"; |
642 bool recorded = true; | 587 bool recorded = true; |
643 if (interstitial_type_ == TYPE_MALWARE) { | 588 if (interstitial_type_ == TYPE_MALWARE) { |
(...skipping 13 matching lines...) Expand all Loading... | |
657 } else if (command == kLearnMoreCommand) { | 602 } else if (command == kLearnMoreCommand) { |
658 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialLearnMore", | 603 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialLearnMore", |
659 dt); | 604 dt); |
660 } else if (command == kNavigatedAwayMetaCommand) { | 605 } else if (command == kNavigatedAwayMetaCommand) { |
661 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeClosed", dt); | 606 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeClosed", dt); |
662 } else if (command == kExpandedSeeMoreCommand) { | 607 } else if (command == kExpandedSeeMoreCommand) { |
663 // Only record the expanded histogram once per display of the | 608 // Only record the expanded histogram once per display of the |
664 // interstitial. | 609 // interstitial. |
665 if (has_expanded_see_more_section_) | 610 if (has_expanded_see_more_section_) |
666 return; | 611 return; |
667 RecordUserAction(SHOW_ADVANCED); | |
668 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeExpandedSeeMore", | 612 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeExpandedSeeMore", |
669 dt); | 613 dt); |
670 has_expanded_see_more_section_ = true; | 614 has_expanded_see_more_section_ = true; |
671 // Expanding the "See More" section doesn't finish the interstitial, so | 615 // Expanding the "See More" section doesn't finish the interstitial, so |
672 // don't mark the reaction time as recorded. | 616 // don't mark the reaction time as recorded. |
673 recorded = false; | 617 recorded = false; |
674 } else { | 618 } else { |
675 recorded = false; | 619 recorded = false; |
676 } | 620 } |
677 } else { | 621 } else { |
678 // Same as above but for phishing warnings. | 622 // Same as above but for phishing warnings. |
679 if (command == kProceedCommand) { | 623 if (command == kProceedCommand) { |
680 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeProceed", dt); | 624 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeProceed", dt); |
681 } else if (command == kTakeMeBackCommand) { | 625 } else if (command == kTakeMeBackCommand) { |
682 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeTakeMeBack", dt); | 626 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeTakeMeBack", dt); |
683 } else if (command == kShowDiagnosticCommand) { | 627 } else if (command == kShowDiagnosticCommand) { |
684 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeReportError", dt); | 628 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeReportError", dt); |
685 } else if (command == kLearnMoreCommand) { | 629 } else if (command == kLearnMoreCommand) { |
686 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeLearnMore", dt); | 630 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeLearnMore", dt); |
687 } else if (command == kNavigatedAwayMetaCommand) { | 631 } else if (command == kNavigatedAwayMetaCommand) { |
688 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeClosed", dt); | 632 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeClosed", dt); |
689 } else if (command == kExpandedSeeMoreCommand) { | 633 } else if (command == kExpandedSeeMoreCommand) { |
690 // Only record the expanded histogram once per display of the | 634 // Only record the expanded histogram once per display of the |
691 // interstitial. | 635 // interstitial. |
692 if (has_expanded_see_more_section_) | 636 if (has_expanded_see_more_section_) |
693 return; | 637 return; |
694 RecordUserAction(SHOW_ADVANCED); | |
695 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeExpandedSeeMore", | 638 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeExpandedSeeMore", |
696 dt); | 639 dt); |
697 has_expanded_see_more_section_ = true; | 640 has_expanded_see_more_section_ = true; |
698 // Expanding the "See More" section doesn't finish the interstitial, so | 641 // Expanding the "See More" section doesn't finish the interstitial, so |
699 // don't mark the reaction time as recorded. | 642 // don't mark the reaction time as recorded. |
700 recorded = false; | 643 recorded = false; |
701 } else { | 644 } else { |
702 recorded = false; | 645 recorded = false; |
703 } | 646 } |
704 } | 647 } |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
893 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, | 836 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, |
894 base::UTF8ToUTF16(url_.host()))); | 837 base::UTF8ToUTF16(url_.host()))); |
895 load_time_data->SetString( | 838 load_time_data->SetString( |
896 "explanationParagraph", | 839 "explanationParagraph", |
897 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, | 840 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, |
898 base::UTF8ToUTF16(url_.host()))); | 841 base::UTF8ToUTF16(url_.host()))); |
899 load_time_data->SetString( | 842 load_time_data->SetString( |
900 "finalParagraph", | 843 "finalParagraph", |
901 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); | 844 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); |
902 } | 845 } |
OLD | NEW |