| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // Constants for the Experience Sampling instrumentation. | 106 // Constants for the Experience Sampling instrumentation. |
| 107 #if defined(ENABLE_EXTENSIONS) | 107 #if defined(ENABLE_EXTENSIONS) |
| 108 const char kEventNameMalware[] = "safebrowsing_interstitial_"; | 108 const char kEventNameMalware[] = "safebrowsing_interstitial_"; |
| 109 const char kEventNamePhishing[] = "phishing_interstitial_"; | 109 const char kEventNamePhishing[] = "phishing_interstitial_"; |
| 110 const char kEventNameOther[] = "safebrowsing_other_interstitial_"; | 110 const char kEventNameOther[] = "safebrowsing_other_interstitial_"; |
| 111 #endif | 111 #endif |
| 112 | 112 |
| 113 base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap> | 113 base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap> |
| 114 g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER; | 114 g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER; |
| 115 | 115 |
| 116 // This enum is used for a histogram. Don't reorder, delete, or insert | |
| 117 // elements. New elements should be added before MAX_ACTION only. | |
| 118 enum DetailedDecision { | |
| 119 MALWARE_SHOW_NEW_SITE = 0, | |
| 120 MALWARE_PROCEED_NEW_SITE, | |
| 121 MALWARE_SHOW_CROSS_SITE, | |
| 122 MALWARE_PROCEED_CROSS_SITE, | |
| 123 PHISHING_SHOW_NEW_SITE, | |
| 124 PHISHING_PROCEED_NEW_SITE, | |
| 125 PHISHING_SHOW_CROSS_SITE, | |
| 126 PHISHING_PROCEED_CROSS_SITE, | |
| 127 MAX_DETAILED_ACTION | |
| 128 }; | |
| 129 | |
| 130 void RecordDetailedUserAction(DetailedDecision decision) { | |
| 131 UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialActionDetails", | |
| 132 decision, | |
| 133 MAX_DETAILED_ACTION); | |
| 134 } | |
| 135 | |
| 136 } // namespace | 116 } // namespace |
| 137 | 117 |
| 138 // static | 118 // static |
| 139 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; | 119 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; |
| 140 | 120 |
| 141 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we | 121 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we |
| 142 // don't leak it. | 122 // don't leak it. |
| 143 class SafeBrowsingBlockingPageFactoryImpl | 123 class SafeBrowsingBlockingPageFactoryImpl |
| 144 : public SafeBrowsingBlockingPageFactory { | 124 : public SafeBrowsingBlockingPageFactory { |
| 145 public: | 125 public: |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL); | 174 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL); |
| 195 phishing = true; | 175 phishing = true; |
| 196 } | 176 } |
| 197 } | 177 } |
| 198 DCHECK(phishing || malware); | 178 DCHECK(phishing || malware); |
| 199 if (malware) | 179 if (malware) |
| 200 interstitial_type_ = TYPE_MALWARE; | 180 interstitial_type_ = TYPE_MALWARE; |
| 201 else | 181 else |
| 202 interstitial_type_ = TYPE_PHISHING; | 182 interstitial_type_ = TYPE_PHISHING; |
| 203 | 183 |
| 204 RecordUserAction(SHOW); | 184 RecordUserDecision(SHOW); |
| 185 RecordUserInteraction(TOTAL_VISITS); |
| 186 if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) |
| 187 RecordUserDecision(PROCEEDING_DISABLED); |
| 188 |
| 205 HistoryService* history_service = HistoryServiceFactory::GetForProfile( | 189 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
| 206 Profile::FromBrowserContext(web_contents->GetBrowserContext()), | 190 Profile::FromBrowserContext(web_contents->GetBrowserContext()), |
| 207 Profile::EXPLICIT_ACCESS); | 191 Profile::EXPLICIT_ACCESS); |
| 208 if (history_service) { | 192 if (history_service) { |
| 209 history_service->GetVisibleVisitCountToHost( | 193 history_service->GetVisibleVisitCountToHost( |
| 210 url_, | 194 url_, |
| 211 base::Bind(&SafeBrowsingBlockingPage::OnGotHistoryCount, | 195 base::Bind(&SafeBrowsingBlockingPage::OnGotHistoryCount, |
| 212 base::Unretained(this)), | 196 base::Unretained(this)), |
| 213 &request_tracker_); | 197 &request_tracker_); |
| 214 } | 198 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 return; | 261 return; |
| 278 } | 262 } |
| 279 | 263 |
| 280 if (command == kDontReportCommand) { | 264 if (command == kDontReportCommand) { |
| 281 SetReportingPreference(false); | 265 SetReportingPreference(false); |
| 282 return; | 266 return; |
| 283 } | 267 } |
| 284 | 268 |
| 285 if (command == kLearnMoreCommand) { | 269 if (command == kLearnMoreCommand) { |
| 286 // User pressed "Learn more". | 270 // User pressed "Learn more". |
| 287 #if defined(ENABLE_EXTENSIONS) | 271 RecordUserInteraction(SHOW_LEARN_MORE); |
| 288 if (sampling_event_.get()) | |
| 289 sampling_event_->set_has_viewed_learn_more(true); | |
| 290 #endif | |
| 291 GURL learn_more_url(interstitial_type_ == TYPE_PHISHING ? | 272 GURL learn_more_url(interstitial_type_ == TYPE_PHISHING ? |
| 292 kLearnMorePhishingUrlV2 : kLearnMoreMalwareUrlV2); | 273 kLearnMorePhishingUrlV2 : kLearnMoreMalwareUrlV2); |
| 293 learn_more_url = google_util::AppendGoogleLocaleParam( | 274 learn_more_url = google_util::AppendGoogleLocaleParam( |
| 294 learn_more_url, g_browser_process->GetApplicationLocale()); | 275 learn_more_url, g_browser_process->GetApplicationLocale()); |
| 295 OpenURLParams params(learn_more_url, | 276 OpenURLParams params(learn_more_url, |
| 296 Referrer(), | 277 Referrer(), |
| 297 CURRENT_TAB, | 278 CURRENT_TAB, |
| 298 content::PAGE_TRANSITION_LINK, | 279 content::PAGE_TRANSITION_LINK, |
| 299 false); | 280 false); |
| 300 web_contents_->OpenURL(params); | 281 web_contents_->OpenURL(params); |
| 301 return; | 282 return; |
| 302 } | 283 } |
| 303 | 284 |
| 304 if (command == kShowPrivacyCommand) { | 285 if (command == kShowPrivacyCommand) { |
| 305 // User pressed "Safe Browsing privacy policy". | 286 // User pressed "Safe Browsing privacy policy". |
| 287 RecordUserInteraction(SHOW_PRIVACY_POLICY); |
| 306 GURL privacy_url( | 288 GURL privacy_url( |
| 307 l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_URL)); | 289 l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_URL)); |
| 308 privacy_url = google_util::AppendGoogleLocaleParam( | 290 privacy_url = google_util::AppendGoogleLocaleParam( |
| 309 privacy_url, g_browser_process->GetApplicationLocale()); | 291 privacy_url, g_browser_process->GetApplicationLocale()); |
| 310 OpenURLParams params(privacy_url, | 292 OpenURLParams params(privacy_url, |
| 311 Referrer(), | 293 Referrer(), |
| 312 CURRENT_TAB, | 294 CURRENT_TAB, |
| 313 content::PAGE_TRANSITION_LINK, | 295 content::PAGE_TRANSITION_LINK, |
| 314 false); | 296 false); |
| 315 web_contents_->OpenURL(params); | 297 web_contents_->OpenURL(params); |
| 316 return; | 298 return; |
| 317 } | 299 } |
| 318 | 300 |
| 319 bool proceed_blocked = false; | 301 bool proceed_blocked = false; |
| 320 if (command == kProceedCommand) { | 302 if (command == kProceedCommand) { |
| 321 if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) { | 303 if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) { |
| 322 proceed_blocked = true; | 304 proceed_blocked = true; |
| 323 } else { | 305 } else { |
| 306 RecordUserDecision(PROCEED); |
| 324 interstitial_page_->Proceed(); | 307 interstitial_page_->Proceed(); |
| 325 // |this| has been deleted after Proceed() returns. | 308 // |this| has been deleted after Proceed() returns. |
| 326 return; | 309 return; |
| 327 } | 310 } |
| 328 } | 311 } |
| 329 | 312 |
| 330 if (command == kTakeMeBackCommand || proceed_blocked) { | 313 if (command == kTakeMeBackCommand || proceed_blocked) { |
| 314 // Don't record the user action here because there are other ways of |
| 315 // triggering DontProceed, like clicking the back button. |
| 331 if (is_main_frame_load_blocked_) { | 316 if (is_main_frame_load_blocked_) { |
| 332 // If the load is blocked, we want to close the interstitial and discard | 317 // If the load is blocked, we want to close the interstitial and discard |
| 333 // the pending entry. | 318 // the pending entry. |
| 334 interstitial_page_->DontProceed(); | 319 interstitial_page_->DontProceed(); |
| 335 // |this| has been deleted after DontProceed() returns. | 320 // |this| has been deleted after DontProceed() returns. |
| 336 return; | 321 return; |
| 337 } | 322 } |
| 338 | 323 |
| 339 // Otherwise the offending entry has committed, and we need to go back or | 324 // Otherwise the offending entry has committed, and we need to go back or |
| 340 // to a safe page. We will close the interstitial when that page commits. | 325 // to a safe page. We will close the interstitial when that page commits. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 367 } | 352 } |
| 368 | 353 |
| 369 if (element_index >= unsafe_resources_.size()) { | 354 if (element_index >= unsafe_resources_.size()) { |
| 370 NOTREACHED(); | 355 NOTREACHED(); |
| 371 return; | 356 return; |
| 372 } | 357 } |
| 373 | 358 |
| 374 std::string bad_url_spec = unsafe_resources_[element_index].url.spec(); | 359 std::string bad_url_spec = unsafe_resources_[element_index].url.spec(); |
| 375 if (command == kShowDiagnosticCommand) { | 360 if (command == kShowDiagnosticCommand) { |
| 376 // We're going to take the user to Google's SafeBrowsing diagnostic page. | 361 // We're going to take the user to Google's SafeBrowsing diagnostic page. |
| 362 RecordUserInteraction(SHOW_DIAGNOSTIC); |
| 377 std::string diagnostic = | 363 std::string diagnostic = |
| 378 base::StringPrintf(kSbDiagnosticUrl, | 364 base::StringPrintf(kSbDiagnosticUrl, |
| 379 net::EscapeQueryParamValue(bad_url_spec, true).c_str()); | 365 net::EscapeQueryParamValue(bad_url_spec, true).c_str()); |
| 380 GURL diagnostic_url(diagnostic); | 366 GURL diagnostic_url(diagnostic); |
| 381 diagnostic_url = google_util::AppendGoogleLocaleParam( | 367 diagnostic_url = google_util::AppendGoogleLocaleParam( |
| 382 diagnostic_url, g_browser_process->GetApplicationLocale()); | 368 diagnostic_url, g_browser_process->GetApplicationLocale()); |
| 383 DCHECK(unsafe_resources_[element_index].threat_type == | 369 DCHECK(unsafe_resources_[element_index].threat_type == |
| 384 SB_THREAT_TYPE_URL_MALWARE || | 370 SB_THREAT_TYPE_URL_MALWARE || |
| 385 unsafe_resources_[element_index].threat_type == | 371 unsafe_resources_[element_index].threat_type == |
| 386 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL); | 372 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL); |
| 387 OpenURLParams params( | 373 OpenURLParams params( |
| 388 diagnostic_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, | 374 diagnostic_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, |
| 389 false); | 375 false); |
| 390 web_contents_->OpenURL(params); | 376 web_contents_->OpenURL(params); |
| 391 return; | 377 return; |
| 392 } | 378 } |
| 393 | 379 |
| 394 if (command == kExpandedSeeMoreCommand) { | 380 if (command == kExpandedSeeMoreCommand) { |
| 395 #if defined(ENABLE_EXTENSIONS) | 381 RecordUserInteraction(SHOW_ADVANCED); |
| 396 // ExperienceSampling: We track that the user expanded the details. | |
| 397 if (sampling_event_.get()) | |
| 398 sampling_event_->set_has_viewed_details(true); | |
| 399 #endif | |
| 400 return; | 382 return; |
| 401 } | 383 } |
| 402 | 384 |
| 403 NOTREACHED() << "Unexpected command: " << command; | 385 NOTREACHED() << "Unexpected command: " << command; |
| 404 } | 386 } |
| 405 | 387 |
| 406 void SafeBrowsingBlockingPage::OverrideRendererPrefs( | 388 void SafeBrowsingBlockingPage::OverrideRendererPrefs( |
| 407 content::RendererPreferences* prefs) { | 389 content::RendererPreferences* prefs) { |
| 408 Profile* profile = Profile::FromBrowserContext( | 390 Profile* profile = Profile::FromBrowserContext( |
| 409 web_contents_->GetBrowserContext()); | 391 web_contents_->GetBrowserContext()); |
| 410 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile); | 392 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile); |
| 411 } | 393 } |
| 412 | 394 |
| 413 void SafeBrowsingBlockingPage::SetReportingPreference(bool report) { | 395 void SafeBrowsingBlockingPage::SetReportingPreference(bool report) { |
| 414 Profile* profile = Profile::FromBrowserContext( | 396 Profile* profile = Profile::FromBrowserContext( |
| 415 web_contents_->GetBrowserContext()); | 397 web_contents_->GetBrowserContext()); |
| 416 PrefService* pref = profile->GetPrefs(); | 398 PrefService* pref = profile->GetPrefs(); |
| 417 pref->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, report); | 399 pref->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, report); |
| 418 UMA_HISTOGRAM_BOOLEAN("SB2.SetExtendedReportingEnabled", report); | 400 UMA_HISTOGRAM_BOOLEAN("SB2.SetExtendedReportingEnabled", report); |
| 419 } | 401 } |
| 420 | 402 |
| 421 void SafeBrowsingBlockingPage::OnProceed() { | 403 void SafeBrowsingBlockingPage::OnProceed() { |
| 422 proceeded_ = true; | 404 proceeded_ = true; |
| 423 RecordUserAction(PROCEED); | |
| 424 // Send the malware details, if we opted to. | 405 // Send the malware details, if we opted to. |
| 425 FinishMalwareDetails(malware_details_proceed_delay_ms_); | 406 FinishMalwareDetails(malware_details_proceed_delay_ms_); |
| 426 | 407 |
| 427 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, true); | 408 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, true); |
| 428 | 409 |
| 429 // Check to see if some new notifications of unsafe resources have been | 410 // Check to see if some new notifications of unsafe resources have been |
| 430 // received while we were showing the interstitial. | 411 // received while we were showing the interstitial. |
| 431 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); | 412 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); |
| 432 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents_); | 413 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents_); |
| 433 SafeBrowsingBlockingPage* blocking_page = NULL; | 414 SafeBrowsingBlockingPage* blocking_page = NULL; |
| 434 if (iter != unsafe_resource_map->end() && !iter->second.empty()) { | 415 if (iter != unsafe_resource_map->end() && !iter->second.empty()) { |
| 435 // Build an interstitial for all the unsafe resources notifications. | 416 // Build an interstitial for all the unsafe resources notifications. |
| 436 // Don't show it now as showing an interstitial while an interstitial is | 417 // Don't show it now as showing an interstitial while an interstitial is |
| 437 // already showing would cause DontProceed() to be invoked. | 418 // already showing would cause DontProceed() to be invoked. |
| 438 blocking_page = factory_->CreateSafeBrowsingPage(ui_manager_, web_contents_, | 419 blocking_page = factory_->CreateSafeBrowsingPage(ui_manager_, web_contents_, |
| 439 iter->second); | 420 iter->second); |
| 440 unsafe_resource_map->erase(iter); | 421 unsafe_resource_map->erase(iter); |
| 441 } | 422 } |
| 442 | 423 |
| 443 #if defined(ENABLE_EXTENSIONS) | |
| 444 // ExperienceSampling: Notify that user decided to proceed. | |
| 445 if (sampling_event_.get()) | |
| 446 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kProceed); | |
| 447 #endif | |
| 448 | |
| 449 // Now that this interstitial is gone, we can show the new one. | 424 // Now that this interstitial is gone, we can show the new one. |
| 450 if (blocking_page) | 425 if (blocking_page) |
| 451 blocking_page->Show(); | 426 blocking_page->Show(); |
| 452 } | 427 } |
| 453 | 428 |
| 454 void SafeBrowsingBlockingPage::DontCreateViewForTesting() { | 429 void SafeBrowsingBlockingPage::DontCreateViewForTesting() { |
| 455 create_view_ = false; | 430 create_view_ = false; |
| 456 } | 431 } |
| 457 | 432 |
| 458 void SafeBrowsingBlockingPage::Show() { | 433 void SafeBrowsingBlockingPage::Show() { |
| 459 DCHECK(!interstitial_page_); | 434 DCHECK(!interstitial_page_); |
| 460 interstitial_page_ = InterstitialPage::Create( | 435 interstitial_page_ = InterstitialPage::Create( |
| 461 web_contents_, is_main_frame_load_blocked_, url_, this); | 436 web_contents_, is_main_frame_load_blocked_, url_, this); |
| 462 if (!create_view_) | 437 if (!create_view_) |
| 463 interstitial_page_->DontCreateViewForTesting(); | 438 interstitial_page_->DontCreateViewForTesting(); |
| 464 interstitial_page_->Show(); | 439 interstitial_page_->Show(); |
| 465 } | 440 } |
| 466 | 441 |
| 467 void SafeBrowsingBlockingPage::OnDontProceed() { | 442 void SafeBrowsingBlockingPage::OnDontProceed() { |
| 468 // We could have already called Proceed(), in which case we must not notify | 443 // We could have already called Proceed(), in which case we must not notify |
| 469 // the SafeBrowsingUIManager again, as the client has been deleted. | 444 // the SafeBrowsingUIManager again, as the client has been deleted. |
| 470 if (proceeded_) | 445 if (proceeded_) |
| 471 return; | 446 return; |
| 472 | 447 |
| 473 RecordUserAction(DONT_PROCEED); | 448 if (!IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) |
| 449 RecordUserDecision(DONT_PROCEED); |
| 450 |
| 474 // Send the malware details, if we opted to. | 451 // Send the malware details, if we opted to. |
| 475 FinishMalwareDetails(0); // No delay | 452 FinishMalwareDetails(0); // No delay |
| 476 | 453 |
| 477 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, false); | 454 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, false); |
| 478 | 455 |
| 479 // The user does not want to proceed, clear the queued unsafe resources | 456 // The user does not want to proceed, clear the queued unsafe resources |
| 480 // notifications we received while the interstitial was showing. | 457 // notifications we received while the interstitial was showing. |
| 481 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); | 458 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); |
| 482 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents_); | 459 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents_); |
| 483 if (iter != unsafe_resource_map->end() && !iter->second.empty()) { | 460 if (iter != unsafe_resource_map->end() && !iter->second.empty()) { |
| 484 NotifySafeBrowsingUIManager(ui_manager_, iter->second, false); | 461 NotifySafeBrowsingUIManager(ui_manager_, iter->second, false); |
| 485 unsafe_resource_map->erase(iter); | 462 unsafe_resource_map->erase(iter); |
| 486 } | 463 } |
| 487 | 464 |
| 488 // We don't remove the navigation entry if the tab is being destroyed as this | 465 // We don't remove the navigation entry if the tab is being destroyed as this |
| 489 // would trigger a navigation that would cause trouble as the render view host | 466 // would trigger a navigation that would cause trouble as the render view host |
| 490 // for the tab has by then already been destroyed. We also don't delete the | 467 // for the tab has by then already been destroyed. We also don't delete the |
| 491 // current entry if it has been committed again, which is possible on a page | 468 // current entry if it has been committed again, which is possible on a page |
| 492 // that had a subresource warning. | 469 // that had a subresource warning. |
| 493 int last_committed_index = | 470 int last_committed_index = |
| 494 web_contents_->GetController().GetLastCommittedEntryIndex(); | 471 web_contents_->GetController().GetLastCommittedEntryIndex(); |
| 495 if (navigation_entry_index_to_remove_ != -1 && | 472 if (navigation_entry_index_to_remove_ != -1 && |
| 496 navigation_entry_index_to_remove_ != last_committed_index && | 473 navigation_entry_index_to_remove_ != last_committed_index && |
| 497 !web_contents_->IsBeingDestroyed()) { | 474 !web_contents_->IsBeingDestroyed()) { |
| 498 CHECK(web_contents_->GetController().RemoveEntryAtIndex( | 475 CHECK(web_contents_->GetController().RemoveEntryAtIndex( |
| 499 navigation_entry_index_to_remove_)); | 476 navigation_entry_index_to_remove_)); |
| 500 navigation_entry_index_to_remove_ = -1; | 477 navigation_entry_index_to_remove_ = -1; |
| 501 } | 478 } |
| 502 | |
| 503 #if defined(ENABLE_EXTENSIONS) | |
| 504 // ExperienceSampling: Notify that user decided to go back. | |
| 505 // This also occurs if the user navigates away or closes the tab. | |
| 506 if (sampling_event_.get()) | |
| 507 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kDeny); | |
| 508 #endif | |
| 509 } | 479 } |
| 510 | 480 |
| 511 void SafeBrowsingBlockingPage::OnGotHistoryCount(bool success, | 481 void SafeBrowsingBlockingPage::OnGotHistoryCount(bool success, |
| 512 int num_visits, | 482 int num_visits, |
| 513 base::Time first_visit) { | 483 base::Time first_visit) { |
| 514 if (success) | 484 if (success) |
| 515 num_visits_ = num_visits; | 485 num_visits_ = num_visits; |
| 516 } | 486 } |
| 517 | 487 |
| 518 void SafeBrowsingBlockingPage::RecordUserAction(BlockingPageEvent event) { | 488 void SafeBrowsingBlockingPage::RecordUserDecision(Decision decision) { |
| 519 // This enum is used for a histogram. Don't reorder, delete, or insert | 489 switch (interstitial_type_) { |
| 520 // elements. New elements should be added before MAX_ACTION only. | 490 case TYPE_MALWARE: |
| 521 enum { | 491 UMA_HISTOGRAM_ENUMERATION("interstitial.malware.decision", |
| 522 MALWARE_SHOW = 0, | 492 decision, |
| 523 MALWARE_DONT_PROCEED, | 493 MAX_DECISION); |
| 524 MALWARE_FORCED_DONT_PROCEED, | |
| 525 MALWARE_PROCEED, | |
| 526 MULTIPLE_SHOW, | |
| 527 MULTIPLE_DONT_PROCEED, | |
| 528 MULTIPLE_FORCED_DONT_PROCEED, | |
| 529 MULTIPLE_PROCEED, | |
| 530 PHISHING_SHOW, | |
| 531 PHISHING_DONT_PROCEED, | |
| 532 PHISHING_FORCED_DONT_PROCEED, | |
| 533 PHISHING_PROCEED, | |
| 534 MALWARE_SHOW_ADVANCED, | |
| 535 MULTIPLE_SHOW_ADVANCED, | |
| 536 PHISHING_SHOW_ADVANCED, | |
| 537 MAX_ACTION | |
| 538 } histogram_action = MAX_ACTION; | |
| 539 | |
| 540 switch (event) { | |
| 541 case SHOW: | |
| 542 switch (interstitial_type_) { | |
| 543 case TYPE_MALWARE: | |
| 544 histogram_action = MALWARE_SHOW; | |
| 545 break; | |
| 546 case TYPE_PHISHING: | |
| 547 histogram_action = PHISHING_SHOW; | |
| 548 break; | |
| 549 } | |
| 550 break; | 494 break; |
| 551 case PROCEED: | 495 case TYPE_PHISHING: |
| 552 switch (interstitial_type_) { | 496 UMA_HISTOGRAM_ENUMERATION("interstitial.phishing.decision", |
| 553 case TYPE_MALWARE: | 497 decision, |
| 554 histogram_action = MALWARE_PROCEED; | 498 MAX_DECISION); |
| 555 break; | |
| 556 case TYPE_PHISHING: | |
| 557 histogram_action = PHISHING_PROCEED; | |
| 558 break; | |
| 559 } | |
| 560 break; | |
| 561 case DONT_PROCEED: | |
| 562 if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) { | |
| 563 switch (interstitial_type_) { | |
| 564 case TYPE_MALWARE: | |
| 565 histogram_action = MALWARE_FORCED_DONT_PROCEED; | |
| 566 break; | |
| 567 case TYPE_PHISHING: | |
| 568 histogram_action = PHISHING_FORCED_DONT_PROCEED; | |
| 569 break; | |
| 570 } | |
| 571 } else { | |
| 572 switch (interstitial_type_) { | |
| 573 case TYPE_MALWARE: | |
| 574 histogram_action = MALWARE_DONT_PROCEED; | |
| 575 break; | |
| 576 case TYPE_PHISHING: | |
| 577 histogram_action = PHISHING_DONT_PROCEED; | |
| 578 break; | |
| 579 } | |
| 580 } | |
| 581 break; | |
| 582 case SHOW_ADVANCED: | |
| 583 switch (interstitial_type_) { | |
| 584 case TYPE_MALWARE: | |
| 585 histogram_action = MALWARE_SHOW_ADVANCED; | |
| 586 break; | |
| 587 case TYPE_PHISHING: | |
| 588 histogram_action = PHISHING_SHOW_ADVANCED; | |
| 589 break; | |
| 590 } | |
| 591 break; | 499 break; |
| 592 default: | 500 default: |
| 593 NOTREACHED() << "Unexpected event: " << event; | 501 NOTREACHED(); |
| 594 } | |
| 595 if (histogram_action == MAX_ACTION) { | |
| 596 NOTREACHED(); | |
| 597 } else { | |
| 598 UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialAction", histogram_action, | |
| 599 MAX_ACTION); | |
| 600 } | 502 } |
| 601 | 503 |
| 602 if (event == PROCEED || event == DONT_PROCEED) { | 504 #if defined(ENABLE_EXTENSIONS) |
| 603 if (num_visits_ == 0) { | 505 if (sampling_event_.get()) { |
| 604 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? | 506 switch (decision) { |
| 605 MALWARE_SHOW_NEW_SITE : PHISHING_SHOW_NEW_SITE); | 507 case PROCEED: |
| 606 if (event == PROCEED) { | 508 sampling_event_->CreateUserDecisionEvent( |
| 607 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? | 509 ExperienceSamplingEvent::kProceed); |
| 608 MALWARE_PROCEED_NEW_SITE : PHISHING_PROCEED_NEW_SITE); | 510 break; |
| 609 } | 511 case DONT_PROCEED: |
| 512 sampling_event_->CreateUserDecisionEvent( |
| 513 ExperienceSamplingEvent::kDeny); |
| 514 break; |
| 515 case SHOW: |
| 516 case PROCEEDING_DISABLED: |
| 517 case MAX_DECISION: |
| 518 break; |
| 610 } | 519 } |
| 611 if (unsafe_resources_[0].is_subresource) { | 520 } |
| 612 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? | 521 #endif |
| 613 MALWARE_SHOW_CROSS_SITE : PHISHING_SHOW_CROSS_SITE); | 522 |
| 614 if (event == PROCEED) { | 523 // Record additional information about malware sites that users have |
| 615 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? | 524 // visited before. |
| 616 MALWARE_PROCEED_CROSS_SITE : PHISHING_PROCEED_CROSS_SITE); | 525 if (num_visits_ < 1 || interstitial_type_ != TYPE_MALWARE) |
| 617 } | 526 return; |
| 618 } | 527 if (decision == PROCEED || decision == DONT_PROCEED) { |
| 528 UMA_HISTOGRAM_ENUMERATION("interstitial.malware.decision.repeat_visit", |
| 529 SHOW, |
| 530 MAX_DECISION); |
| 531 UMA_HISTOGRAM_ENUMERATION("interstitial.malware.decision.repeat_visit", |
| 532 decision, |
| 533 MAX_DECISION); |
| 619 } | 534 } |
| 620 } | 535 } |
| 621 | 536 |
| 537 void SafeBrowsingBlockingPage::RecordUserInteraction(Interaction interaction) { |
| 538 switch (interstitial_type_) { |
| 539 case TYPE_MALWARE: |
| 540 UMA_HISTOGRAM_ENUMERATION("interstitial.malware.interaction", |
| 541 interaction, |
| 542 MAX_INTERACTION); |
| 543 break; |
| 544 case TYPE_PHISHING: |
| 545 UMA_HISTOGRAM_ENUMERATION("interstitial.phishing.interaction", |
| 546 interaction, |
| 547 MAX_INTERACTION); |
| 548 break; |
| 549 default: |
| 550 NOTREACHED(); |
| 551 } |
| 552 |
| 553 #if defined(ENABLE_EXTENSIONS) |
| 554 if (!sampling_event_.get()) |
| 555 return; |
| 556 switch (interaction) { |
| 557 case SHOW_LEARN_MORE: |
| 558 sampling_event_->set_has_viewed_learn_more(true); |
| 559 break; |
| 560 case SHOW_ADVANCED: |
| 561 sampling_event_->set_has_viewed_details(true); |
| 562 break; |
| 563 case SHOW_PRIVACY_POLICY: |
| 564 case SHOW_DIAGNOSTIC: |
| 565 case TOTAL_VISITS: |
| 566 case MAX_INTERACTION: |
| 567 break; |
| 568 } |
| 569 #endif |
| 570 } |
| 571 |
| 622 void SafeBrowsingBlockingPage::FinishMalwareDetails(int64 delay_ms) { | 572 void SafeBrowsingBlockingPage::FinishMalwareDetails(int64 delay_ms) { |
| 623 if (malware_details_.get() == NULL) | 573 if (malware_details_.get() == NULL) |
| 624 return; // Not all interstitials have malware details (eg phishing). | 574 return; // Not all interstitials have malware details (eg phishing). |
| 625 | 575 |
| 626 const bool enabled = | 576 const bool enabled = |
| 627 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled); | 577 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled); |
| 628 UMA_HISTOGRAM_BOOLEAN("SB2.ExtendedReportingIsEnabled", enabled); | 578 UMA_HISTOGRAM_BOOLEAN("SB2.ExtendedReportingIsEnabled", enabled); |
| 629 if (enabled) { | 579 if (enabled) { |
| 630 // Finish the malware details collection, send it over. | 580 // Finish the malware details collection, send it over. |
| 631 BrowserThread::PostDelayedTask( | 581 BrowserThread::PostDelayedTask( |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, | 754 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, |
| 805 base::UTF8ToUTF16(url_.host()))); | 755 base::UTF8ToUTF16(url_.host()))); |
| 806 load_time_data->SetString( | 756 load_time_data->SetString( |
| 807 "explanationParagraph", | 757 "explanationParagraph", |
| 808 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, | 758 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, |
| 809 base::UTF8ToUTF16(url_.host()))); | 759 base::UTF8ToUTF16(url_.host()))); |
| 810 load_time_data->SetString( | 760 load_time_data->SetString( |
| 811 "finalParagraph", | 761 "finalParagraph", |
| 812 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); | 762 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); |
| 813 } | 763 } |
| OLD | NEW |