| 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 else | 279 else |
| 280 interstitial_type_ = TYPE_PHISHING; | 280 interstitial_type_ = TYPE_PHISHING; |
| 281 | 281 |
| 282 RecordUserAction(SHOW); | 282 RecordUserAction(SHOW); |
| 283 HistoryService* history_service = HistoryServiceFactory::GetForProfile( | 283 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
| 284 Profile::FromBrowserContext(web_contents->GetBrowserContext()), | 284 Profile::FromBrowserContext(web_contents->GetBrowserContext()), |
| 285 Profile::EXPLICIT_ACCESS); | 285 Profile::EXPLICIT_ACCESS); |
| 286 if (history_service) { | 286 if (history_service) { |
| 287 history_service->GetVisibleVisitCountToHost( | 287 history_service->GetVisibleVisitCountToHost( |
| 288 url_, | 288 url_, |
| 289 &request_consumer_, | |
| 290 base::Bind(&SafeBrowsingBlockingPage::OnGotHistoryCount, | 289 base::Bind(&SafeBrowsingBlockingPage::OnGotHistoryCount, |
| 291 base::Unretained(this))); | 290 base::Unretained(this)), |
| 291 &request_tracker_); |
| 292 } | 292 } |
| 293 | 293 |
| 294 if (!is_main_frame_load_blocked_) { | 294 if (!is_main_frame_load_blocked_) { |
| 295 navigation_entry_index_to_remove_ = | 295 navigation_entry_index_to_remove_ = |
| 296 web_contents->GetController().GetLastCommittedEntryIndex(); | 296 web_contents->GetController().GetLastCommittedEntryIndex(); |
| 297 } else { | 297 } else { |
| 298 navigation_entry_index_to_remove_ = -1; | 298 navigation_entry_index_to_remove_ = -1; |
| 299 } | 299 } |
| 300 | 300 |
| 301 // Start computing malware details. They will be sent only | 301 // Start computing malware details. They will be sent only |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 web_contents_->GetController().GetLastCommittedEntryIndex(); | 587 web_contents_->GetController().GetLastCommittedEntryIndex(); |
| 588 if (navigation_entry_index_to_remove_ != -1 && | 588 if (navigation_entry_index_to_remove_ != -1 && |
| 589 navigation_entry_index_to_remove_ != last_committed_index && | 589 navigation_entry_index_to_remove_ != last_committed_index && |
| 590 !web_contents_->IsBeingDestroyed()) { | 590 !web_contents_->IsBeingDestroyed()) { |
| 591 CHECK(web_contents_->GetController().RemoveEntryAtIndex( | 591 CHECK(web_contents_->GetController().RemoveEntryAtIndex( |
| 592 navigation_entry_index_to_remove_)); | 592 navigation_entry_index_to_remove_)); |
| 593 navigation_entry_index_to_remove_ = -1; | 593 navigation_entry_index_to_remove_ = -1; |
| 594 } | 594 } |
| 595 } | 595 } |
| 596 | 596 |
| 597 void SafeBrowsingBlockingPage::OnGotHistoryCount(HistoryService::Handle handle, | 597 void SafeBrowsingBlockingPage::OnGotHistoryCount(bool success, |
| 598 bool success, | |
| 599 int num_visits, | 598 int num_visits, |
| 600 base::Time first_visit) { | 599 base::Time first_visit) { |
| 601 if (success) | 600 if (success) |
| 602 num_visits_ = num_visits; | 601 num_visits_ = num_visits; |
| 603 } | 602 } |
| 604 | 603 |
| 605 void SafeBrowsingBlockingPage::RecordUserAction(BlockingPageEvent event) { | 604 void SafeBrowsingBlockingPage::RecordUserAction(BlockingPageEvent event) { |
| 606 // This enum is used for a histogram. Don't reorder, delete, or insert | 605 // This enum is used for a histogram. Don't reorder, delete, or insert |
| 607 // elements. New elements should be added before MAX_ACTION only. | 606 // elements. New elements should be added before MAX_ACTION only. |
| 608 enum { | 607 enum { |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1394 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, | 1393 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, |
| 1395 base::UTF8ToUTF16(url_.host()))); | 1394 base::UTF8ToUTF16(url_.host()))); |
| 1396 load_time_data->SetString( | 1395 load_time_data->SetString( |
| 1397 "explanationParagraph", | 1396 "explanationParagraph", |
| 1398 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, | 1397 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, |
| 1399 base::UTF8ToUTF16(url_.host()))); | 1398 base::UTF8ToUTF16(url_.host()))); |
| 1400 load_time_data->SetString( | 1399 load_time_data->SetString( |
| 1401 "finalParagraph", | 1400 "finalParagraph", |
| 1402 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); | 1401 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); |
| 1403 } | 1402 } |
| OLD | NEW |